[Dev-C++] How to hide and show a shell notify icon
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ahmed H. <ahm...@gm...> - 2006-09-26 20:02:30
|
Hello, I am preparing a system tray icon class for Windows XP.
I got stuck at Hide() and Show() member functions. I have no idea what code
should I write for them. Any help will be appreciated.
I tested the other member functions, they are all running with no error.
class CTrayIcon
> {
> private:
>
> public:
> NOTIFYICONDATA Nid;
> CTrayIcon();
> void Create(void);
> void Show(void);
> void Hide(void);
> void Modify(void);
> void Kill(void);
>
> };
>
> CTrayIcon::CTrayIcon()
> {
> Nid.cbSize = (DWORD) sizeof(NOTIFYICONDATA);
> Nid.uFlags = (UINT) NIF_ICON | NIF_MESSAGE | NIF_TIP |
> NIF_STATE | NIF_INFO | NIF_GUID;
> Nid.dwState = (DWORD) NIS_SHAREDICON | NIS_HIDDEN;
> //Nid.dwStateMask = (DWORD) NIS_SHAREDICON | NIS_HIDDEN;
> Nid.uTimeout = (UINT) 10;
> //Nid.uVersion = (UINT) NOTIFYICON_VERSION;
> Nid.dwInfoFlags = (DWORD) NIIF_INFO; // NIIF_ERROR,
> NIIF_NON, NIIF_WARNING, NIIF_ICON_MASK, NIIF_NOSOUND
> //Nid.guidItem = (GUID) NULL; // Version 6.0.
> Reserved
> }
>
> void CTrayIcon::Create(void)
> {
> if(!Shell_NotifyIcon(NIM_ADD, &Nid)) DebugTest("Couldn't create the
> icon.");
> }
>
> void CTrayIcon::Show(void)
> {
>
> //if(!Shell_NotifyIcon(NIM_MODIFY, &Nid)) DebugTest("Couldn't show the
> icon.");
> }
>
> void CTrayIcon::Hide(void)
> {
>
> //if(!Shell_NotifyIcon(NIM_MODIFY, &Nid)) DebugTest("Couldn't hide the
> icon.");
> }
>
> void CTrayIcon::Modify(void)
> {
> if(!Shell_NotifyIcon(NIM_MODIFY, &Nid)) DebugTest("Couldn't modify the
> icon.");
> }
>
> void CTrayIcon::Kill(void)
> {
> if(!Shell_NotifyIcon(NIM_DELETE, &Nid)) DebugTest("Couldn't kill the
> icon.");
> }
>
>
|