Article View: borland.public.cppbuilder.nativeapi
Article #4787Re: Refresh The System Tray
From: Remy Lebeau (TeamB)
Date: Mon, 21 Nov 2005 23:56
Date: Mon, 21 Nov 2005 23:56
34 lines
2775 bytes
2775 bytes
"AJ" <adam_bouchard@sbcglobal.net> wrote in message news:438251cb@newsgroups.borland.com... > PostMessage(hwnd, WM_QUERYENDSESSION, 0, 0) ; > PostMessage(hwnd, WM_ENDSESSION, 0, 0) ; Those messages need to be issued using SendMessage() instead of PostMessage(), and you need to take note of the return value of the WM_QUERYENDSESSION message in particular. Applications are allowed to prevent system shutdown by returning TRUE to WM_QUERYENDSESSION. If that happens, then the application does not wish to be shut down, and you should not be sending WM_ENDSESSION afterwards. Also, you are sending the messages to every window in the application. If you do that, then you should be using the WM_CLOSE message instead. An alternative to using EnumWindows() is to use PostThreadMessage() to issue a WM_QUIT message to the Thread ID that is being passed to TerminateApp(). That will cause the main message queue to terminate, and thus the application to terminate in general. Of course, this requires there to be an active message queue to begin with - just like the code you are currently using depends on there being active windows in the application. So there is a possible tradeoff one way or another. > My reasoning for thinking I could use the Shell_NotifyIcon function > is that this code gives me the HANDLE (HWND) for the application. Perhaps, but there is no guarantee that the HWND you get is the same HWND that placed the system tray icon. Also, the code doesn't tell you which HWND is the main HWND for the application, if any. Gambit
Technical Details
Message-ID:
<43825e81$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!txtfeed1.tudelft.nl!tudelft.nl!txtfeed2.tudelft.nl!feeder.xsnews.nl!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<438201d2@newsgroups.borland.com> <43821387$1@newsgroups.borland.com> <438251cb@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,8ad97936ff76c516 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <438201d2@newsgroups.borland.com> <43821387$1@newsgroups.borland.com> <438251cb@newsgroups.borland.com> Subject: Re: Refresh The System Tray Date: Mon, 21 Nov 2005 15:56:23 -0800 Lines: 36 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <43825e81$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1132617345 68.69.17.41 (21 Nov 2005 15:55:45 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!txtfeed1.tudelft.nl!tudelft.nl!txtfeed2.tudelft.nl!feeder.xsnews.nl!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail