Click to See Complete Forum and Search --> : Detecting print command


bhushank21
February 10th, 2003, 04:42 AM
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

willchop
February 10th, 2003, 09:34 AM
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