Convert any document to PDF, BMP, TIFF, JPEG, PNG...
Windows Vista Windows XP Windows 2000

Monitoring Print2eDoc Print Jobs

Learn to track Windows messages generated by Print2eDoc application.
By Mallika

In Version 1.05, Print2eDoc introduced support for Windows messages.

Or, rather the Print2eDoc application generated certain Windows messages that were broadcast to all applications and a programmer could create an application in Delphi, VB, or VC++ to track these messages.

By tracking these messages, the application would be able to know the status of Print2eDoc printer at any moment in time.

Print2eDoc sends the following messages:

  1. PRINT2EDOC_BEGINDOC - when a conversion job begins
  2. PRINT2EDOC_PROCESSPAGE - when a page is about to be rendered in the output document
  3. PRINT2EDOC_PRINTPAGE - when a page is being rendered in the output document
  4. PRINT2EDOC_ENDDOC - when a particular conversion job has ended
  5. PRINT2EDOC_ABORT - when a particular conversion job is aborted

If an application needs to monitor these messages, it must call the Windows API RegisterWindowMessage() function. This function returns the unique ID that was generated when Print2eDoc registered the messages.

UINT RegisterWindowMessage(
  LPCTSTR lpString   // message string

Then, the application should call the function IsDialogMessage() in a loop to check if the messages it receives are from Print2eDoc.

BOOL IsDialogMessage(
  HWND hDlg,   // handle to dialog box
  LPMSG lpMsg  // message to be checked

The lpMsg argument is a pointer to a MSG structure that will contain the message details.

typedef struct tagMSG {
  HWND   hwnd; 
  UINT   message; 
  WPARAM wParam; 
  LPARAM lParam; 
  DWORD  time; 
  POINT  pt; 

The message member of the MSG structure can be compared with message identifier returned by RegisterWindowMessage() to see if the message processed by IsDialogMessage() comes from Print2eDoc.

With the PRINT2EDOC_PROCESSPAGE message, the page number is sent with the wParam parameter. With the PRINT2EDOC_PRINTPAGE message, the page number is sent with the wParam parameter and the total page count with the lParam. With the PRINT2EDOC_ENDDOC message, the total page count is again sent with the lParam parameter.

In Delphi, you can use the function AllocateHWnd(Method: TWndMethod) to specify a form procedure that will process all messages.

FMessageWndHandle := AllocateHWnd(WinProc);

The specified procedure then needs to check if its TMessage argument is equal to any of the message identifiers provided by the RegisterWindowMessage() function.


// This procedure checks if the message it receives
// comes from Print2eDoc and if it is from 
// Print2eDoc, then it adds more information obtained 
// from the message to a list box.
procedure TfrmEventDemo.WinProc(var Mssg: TMessage);
    with Mssg do
      // Check if the message was sent by Print2eDoc
      if Msg = WM_PRINT2EDOC_BEGINDOC then
        SetLength(str, MAX_PATH);
        Length := 
           GlobalGetAtomName(wParam, PAnsiChar(str), MAX_PATH);
        SetLength(str, Length);
        lstStatus.Items.Add('Beginning to print ' + str );
      else if Msg = WM_PRINT2EDOC_ENDDOC then
        lstStatus.Items.Add('Finished printing ' + str);
      else if Msg = WM_PRINT2EDOC_PRINTPAGE then
                'Printing '+ 
                IntToStr(WParam) + 
                ' of '+ IntToStr(LParam) + 
                ' pages of ' + 
  except on E:Exception do;

In Version 1.1, we added support for using the GlobalGetAtomName() for retrieving the name of the output file.




Our .NET Developer Tools
XtremeDocumentStudio .NET

Multi-format document-processing component suite for .NET developers.


A .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications.

Our Delphi/C++Builder developer tools
XtremeDocumentStudio Delphi

Multi-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms.

eDocEngine VCL

A Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools.

PDFtoolkit VCL

A Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents.

Our Java developer tools
XtremeDocumentStudio (for Java)

Multi-format document-processing component suite for Java developers.

PDFOne (for Java)

A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications.

Our Platform-Agnostic Cloud and On-Premises APIs

Cloud-hosted and On-Premises REST-based document-processing and document-viewing APIs

Privacy | Legal | Feedback | Newsletter | Blog | Resellers © 2002-2017 Gnostice Information Technologies Private Limited. All rights reserved.