Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Minimizing app to system tray with Win32

This thread is locked; no one can reply to it. rss feed Print
Minimizing app to system tray with Win32
slippnslide
Member #7,445
July 2006

Could anyone provide me with a link or an example of a Win32 application that you can minimize to the system tray? Everything I've found requires MFC or it's for Visual Studio 2003 and it doesn't seem to work in Visual Studio 2005. Also, it needs to be in either C or C++.

Thanks in advance for any replies.

Archon
Member #4,195
January 2004
avatar

Look in MSDN.

_Dante
Member #7,398
June 2006
avatar

Specifically, look up Shell_NotifyIcon().

-----------------------------
Anatidaephobia: The fear that somehow, somewhere, a duck is watching you

A J
Member #3,025
December 2002
avatar

1NOTIFYICONDATA nid;
2nid.cbSize = sizeof(NOTIFYICONDATA);
3nid.hWnd = win_get_window();
4nid.uID = 0;
5nid.uFlags = NIF_ICON | NIF_TIP;
6nid.uCallbackMessage = 0;
7char tmp[256];
8get_executable_name(tmp, 256);
9HMODULE hMod = GetModuleHandle(tmp);
10if ( NULL == hMod )
11 log << "failed to GetModuleHandle() ";
12else
13{
14 HICON hIco = LoadIcon( hMod, "ALLEGRO_ICON");
15 if ( NULL == hIco )
16 log << "failed to LoadIcon()";
17 else
18 {
19 nid.hIcon = hIco;
20 strncpy( nid.szTip, "Your app Name", 64 );
21 if ( false == Shell_NotifyIcon( NIM_ADD, &nid ))
22 log << "failed to Shell_NotifyIcon()";
23 }
24}

___________________________
The more you talk, the more AJ is right. - ML

slippnslide
Member #7,445
July 2006

Great, thanks A J. Hopefully between a few Win32 tutorials I finally found and what you gave me, this will work.

Go to: