Printer Dialog box

Is it possible to write a program that once executed will run in the background and detect when the print dialog box is called.

thanks in advance

MICK
mickbAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

naskomCommented:
I think this is unpossible in normal way
I mean there is no DLLs,or functions for this purpose

Maybe you can create a prog. which is loaded in the SysTray for example.

This prog. will be checking for a new windows with caption "Print" each 5 seconds (or whatever you want)

If you want I can give you a procedure which is searching for a specific caption is all active windows

I think that will do this job
0
Jon_RaymondCommented:
If the program is written to print something then why don't you insert whatever notification you want right before it issues the print command?
0
mickbAuthor Commented:
what i want is to detect when other programs call the print box e.g. MS Word

thanks MICK
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

naskomCommented:
So
You can detect when a window with caption "Print" is shown on the desktop

Will this do the job?
0
naskomCommented:
So
You can detect when a window with caption "Print" is shown on the desktop

Will this do the job?

If so tell me to paste you the code as answer please!
0
vbyuvalCommented:
?
0
mickbAuthor Commented:
naskom
i will accept your code as the answer
0
naskomCommented:
OK
It is now difficult.You need just some API functions
Follow the steps below:

So..create an empty form and put on it one timer control and set its interval property to 1000 or 2000 or whatever you need

Then create a module and paste this declarations in:
----------- cut here ----------
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long

Public Declare Function GetNextWindow Lib "user32" Alias "GetWindow" (ByVal hwnd As Long, ByVal wFlag As Long) As Long
----------- cut here ----------

then add this subs and function in your form:

----------- cut here ----------
Public Function GetCaption(formhWnd As Long) As String
    Dim sA As String, lLen As Long
    lLen = GetWindowTextLength(formhWnd&)
    sA = String(lLen, 0)
    Call GetWindowText(formhWnd, sA, lLen + 1)
    GetCaption = sA
End Function

Public Function DLHFindWin(frm As Form, WinTitle As String, CaseSensitive As Boolean) As Long
    Dim formhWnd As Long, sA As String
    formhWnd = frm.hwnd
    Do
    DoEvents
    If formhWnd = 0 Then Exit Do
    If CaseSensitive = False Then
    sA = LCase(GetCaption(formhWnd))
    WinTitle = LCase(WinTitle)
    Else
    sA = GetCaption(formhWnd)
    End If
    If InStr(sA, WinTitle) Then DLHFindWin = formhWnd: Exit Do Else DLHFindWin = 0
    formhWnd = GetNextWindow(formhWnd, 2)
    Loop
End Function
----------- cut here ----------

Now double click on your Timer control and paste this code:
----------- cut here ----------
    a = DLHFindWin(Me, "Print", False)
    If a <> 0 Then MsgBox "Print dialog is activated"
----------- cut here ----------

and now start the program
if there is any problems ask me

so when you load the program in the SysTray it will be always active
That's all
Thank you
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mickbAuthor Commented:
Hi naskom
I've followed your instructions but something isn't working properly.
the message box "Print dialog is activated" appears every second even if there is no printer dialog box.

any suggestions

MICK
0
naskomCommented:
That's inpossible
May be you have window with this caption somewhere

You can see that this message appears only when Print window is found

I have no other ideas
0
naskomCommented:
Which version of VB fo you use?
0
mickbAuthor Commented:
every thing works now
thank you very much
MICK
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.