CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2002
    Posts
    12

    Detecting print command

    Hi,
    Here is my requirement...
    There are different applications like MsWord, NotePad, Wordpad etc. Now my application will be continously running in the background. It should capture the Print command given by the user be it in any application. For eg. When user clicks on the menu -- File --> Print in a word document, a printer dialog box opens up. Now I want to detect this very opening up of the form. Before the user can print anything I want to capture some data from the user.
    Is this possible? Any alternative too would be appreciated.
    Pls help me as soon as possible...

    Thanks in advance,
    Bhushan

  2. #2
    Join Date
    Aug 2002
    Location
    VA, USA
    Posts
    137
    I don't know of any existing hooks that you can use to intercept
    a print action. Hopefully someone else knows of one. Maybe the
    following solution is possible:

    Monitor the window tree for windows that have the word "print"
    in their title bar (or hard code known title bar search text for
    the major printing apps). When you find a window, use the
    handle to get the address of the dialog (CWnd::FromHandle).
    Try to cast the address pointer to a CPrintDialog. You will have
    to be careful with that pointer because the user could have
    destoyed the window before your code actually uses it.

    good luck.
    willchop

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured