Article View: borland.public.cppbuilder.nativeapi
Article #4317Re: Printer notification
From: Bogdan
Date: Fri, 10 Feb 2006 20:52
Date: Fri, 10 Feb 2006 20:52
85 lines
3028 bytes
3028 bytes
> Where are you calling FindFirstPrinterChangeNotification()? Which
> notifications are you asking it for?
Missed some lines when copy-pasted :-).
Flags = PRINTER_CHANGE_ALL;
Notifier = FindFirstPrinterChangeNotification(printer,Flags,0,NULL);
But the thread still terminates cleanly, even with :
while(!Terminated)
{
WaitForSingleObject(Notifier,INFINITE);
....
}
I've tried using the pPrinterNotifyOptions and ppPrinterNotifyInfo options
in the following code
to look for the number of pages printerd so far, but i'm not sure I'm using
them corectly...
shouldn't a notification be sent when one of the monitored parameters
changes?
void __fastcall TPrinterMonitor::Execute()
{
PRINTER_NOTIFY_OPTIONS pno;
PRINTER_NOTIFY_OPTIONS_TYPE pnot;
PRINTER_NOTIFY_INFO *pni = NULL;
WORD Field = JOB_NOTIFY_FIELD_PAGES_PRINTED;
pno.Version = 2;
pno.Flags = PRINTER_NOTIFY_OPTIONS_REFRESH;
pno.Count = 1;
pno.pTypes = &pnot;
pnot.Type = JOB_NOTIFY_TYPE;
pnot.Reserved0 = 0;
pnot.Reserved1 = 0;
pnot.Reserved2 = 0;
pnot.Count = 1;
pnot.pFields = &Field;
PPRINTER_NOTIFY_INFO ppni;
Notifier = FindFirstPrinterChangeNotification(printer,MonitorFlags,0,&pno);
while(!Terminated)
{
WaitForSingleObject(Notifier,INFINITE);
Changes = 0x00000000;
if(FindNextPrinterChangeNotification(Notifier,&Changes,&pno,(void**)&pni))
{
if(Changes & PRINTER_CHANGE_ADD_JOB)
{
Line = "Job added";
Synchronize(Update);
//Sleep(100);
//Synchronize(ListJobs);
}
else if(Changes & PRINTER_CHANGE_DELETE_JOB)
{
Line = "Job deleted";
Synchronize(Update);
}
else if(Changes & PRINTER_CHANGE_SET_JOB)
{
Line = "Job set";
Synchronize(Update);
}
else if(Changes & PRINTER_CHANGE_WRITE_JOB)
{
Line = "Job write";
Synchronize(Update);
}
else
{
Line = "some other change";
Synchronize(Update);
};
};
};
FindClosePrinterChangeNotification(Notifier);
}
Bogdan
Technical Details
Message-ID:
<43ecfc34$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!news.glorb.com!newsfeed.inode.at!reader.uucp.at!newsfeed.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mailReferences:
<43ecd5bb@newsgroups.borland.com> <43ecf638$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,2eb2d0dc0d96a498 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Bogdan" <boprea@xnet.ro> From: "Bogdan" <boprea@xnet.ro> Newsgroups: borland.public.cppbuilder.nativeapi References: <43ecd5bb@newsgroups.borland.com> <43ecf638$1@newsgroups.borland.com> Subject: Re: Printer notification Date: Fri, 10 Feb 2006 22:52:37 +0200 Lines: 88 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 85.186.237.190 Message-ID: <43ecfc34$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1139604532 85.186.237.190 (10 Feb 2006 12:48:52 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!news.glorb.com!newsfeed.inode.at!reader.uucp.at!newsfeed.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mail