Thanks for your help but tell me please; must I use a timer to intercept the WM_SPOOLERSTATUS messages?
In fact, I don't know in advance which application user will use to print; I thought that I was able to use a timer in which I could scan my printer's status and jobs... But If I use this method, I could intercept the signal a little seconds late.
My problems is that when a user wants to print since any application in Windows 9x/2000, I would like to pause the printing, ask him some informations and if the anwsers are right,continue with printing otherwise cancel it...
What's the best way to do this?
Thanks in advance.
09-07-2002 at 01:18 PM
|
Merrion Level: VB Guru Registered: 15-04-2002 Posts: 37
Re: Thanks but ... Archived to Disk
When a job is added or removed from the print queue in Windows 95/98/Me the message wm_spoolerstatus is sent to every application's main window.
Unfortunately this message is just ignored by VB and so no event is generated.
However it is possible to subclass your application's main window and thereby intercept that message.
Subclassing is a very advanced programming technique - however I have written a dll - EventVB that makes this a lot easier...
you can do this thus:
Dim WithEvents vbLink As EventVB.ApiFunctions
Dim WithEvents vbWnd As EventVB.ApiWindow
Private Sub Form_Load()
Set vbLink = New ApiFunctions
Set vbWnd = New ApiWindow
vbWnd.hwnd = Me.hwnd
vbLink.SubclassedWindows.Add vbWnd
End Sub
Private Sub vbWnd_WindowMessageFired(ByVal msg As WindowMessages, ByVal wParam As Long, ByVal lParam As Long, Cancel As Boolean, ProcRet As Long)
If msg = WM_SPOOLERSTATUS Then
' A print job was added or removed...