Print2eDoc
Convert any document to PDF, BMP, TIFF, JPEG, PNG...
Compatibility
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; 
} MSG, *PMSG;

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.

Application.ProcessMessages;
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.

WM_PRINT2EDOC_BEGINDOC := 
  RegisterWindowMessage('PRINT2EDOC_BEGINDOC');
WM_PRINT2EDOC_PROCESSPAGE := 
  RegisterWindowMessage('PRINT2EDOC_PROCESSPAGE');
WM_PRINT2EDOC_ENDDOC := 
  RegisterWindowMessage('PRINT2EDOC_ENDDOC');
WM_PRINT2EDOC_PRINTPAGE := 
  RegisterWindowMessage('PRINT2EDOC_PRINTPAGE');
WM_PRINT2EDOC_ABORT := 
  RegisterWindowMessage('PRINT2EDOC_ABORT');

...
// 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);
begin
  try
    with Mssg do
    begin
      // Check if the message was sent by Print2eDoc
      if Msg = WM_PRINT2EDOC_BEGINDOC then
      begin
        SetLength(str, MAX_PATH);
        Length := 
           GlobalGetAtomName(wParam, PAnsiChar(str), MAX_PATH);
        SetLength(str, Length);
        lstStatus.Items.Add('Beginning to print ' + str );
      end
      else if Msg = WM_PRINT2EDOC_ENDDOC then
      begin
        lstStatus.Items.Add('Finished printing ' + str);
      end
      else if Msg = WM_PRINT2EDOC_PRINTPAGE then
      begin
        lstStatus.Items.Add(
                'Printing '+ 
                IntToStr(WParam) + 
                ' of '+ IntToStr(LParam) + 
                ' pages of ' + 
                str);
      end
    end;
  except on E:Exception do;
end

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

---o0O0o---

Downloads:

---o0O0o---

Our Free Online Document-Processing Tools
Gnostice Apps

Gnostice Apps provides several PDF document-processing services over the Web. It enables you to merge, split, convert, secure and redact PDF documents - all for FREE. All you need to access these services is a HTML5-capable browser such as the latest version of Firefox/Seamonkey or IE 11.

Our Developer Tools
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.

XtremePDFConverter VCL

A Delphi/C++Builder component to intelligently convert PDF to user-friendly Word RTF documents.

PDFOne .NET

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

XtremeDocumentStudio .NET

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

PDFOne (for Java™)

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

XtremeFontEngine (for Java)

Java font engine to render glyphs from Type 1, Type 2 (CFF), and TrueType fonts

Our Office Productivity Applications
Free PDF Reader

A free, fast, and portable application for viewing, printing and converting PDF documents.

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

This site is best viewed on a screen with minimum resolution of 1152 x 864 pixels. Windows XP users are advised to use Microsoft ClearType Tuning for optimal experience. Also, please use the latest version of a standards-compliant browser such as Firefox, Opera, or Dragon (Chromium).