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 Cloud-based document-processing
Gnostice StarDocs

Gnostice StarDocs is a scalable, fault-tolerant document-processing server solution, designed to be the central go-to place for all kinds of electronic document-processing work. StarDocs includes a web application (as seen at stardocs.gnostice.com) that frees your end-users from the need to have format-specific software to merge, split, redact, convert, edit, and sign documents - all they need is a network connection and a HTML5 browser. StarDocs provides a REST-based API that your developers can use to add document-processing functions to a variety of software applications. As the REST API is platform agnostic, your developers can write software on a wide variety of platforms - from desktop to mobile devices to Web services in any development language. To get them started quickly, StarDocs is supported by language-specific native SDK. StarDocs document server has load-balancing built-in and is designed to be scalable across enterprise Intranets and the Internet. StarDocs is available as packaged software for on-premise hosting and also as a subscription-based cloud service.

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.

XtremePDFConverter VCL

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

Our .NET Developer Tools
XtremeDocumentStudio .NET

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

PDFOne .NET

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

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 office-productivity applications
Free PDF Reader

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

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