Click to See Complete Forum and Search --> : DialogBox() with tray icons


slippnslide
July 26th, 2006, 01:52 AM
I'm using DialogBox() with a resource file to create my window. That works fine and dandy, but how do I use tray icons also? I have tray icons working fine with CreateWindowEx(). The tray icon struct calls for a window handle, but setting it to NULL or using "HWND hWnd" and not setting hWnd to anything doesn't work. It makes the icon show up, but on mouseover, it disappears. Also, I use CreatePopupMenu() and AppendMenu() to create a menu when you right click the icon. To fix a bug, you have to use "SetForegroundWindow(hWnd);". But, if there is no window, I can't use hWnd.

So, how would I go about fixing this? Would I just create a 1x1 window and never show it?

ovidiucucu
July 26th, 2006, 07:49 AM
I do not understand your problem.
A dialog box is also a window and is also identified by a window handle (HWND).

slippnslide
July 26th, 2006, 10:59 AM
Umm, according to MSDN it doesn't. It only takes a parent window's handle.

Also, another problem is that I can't use WindowProc() with the dialog box. That means that I'm going to have to have 2 message queues.

ovidiucucu
July 27th, 2006, 05:33 AM
Ummm, you may have taken a false conclusion... looking at returning type. While CreateWindowEx returns a HWND, DialogBox does not.
Just note that:

a dialog box is also a window (even a "special" one), and every window is identified by a window handle.
DialogBox creates a modal dialog and does not return until the dialog is destroyed; that's the reason it doesn't return a HWND which is anyhow useless in that moment.
unless you create a dummy dialog box, you have to define an application-defined dialog box procedure (which is not identical but quite similar to window procedure; that doesn't mean additional message queue; in that dialog procedure the dialog window handle is passed as parameter.

Well, to shorten everything, here is attached a sample Win32 application with a modal dialog created using DialogBox and having a taskbar (tray) icon.

slippnslide
July 27th, 2006, 07:52 PM
Well, I got everything to work for the most part. I just settled on CreateDialog(). But, how does you make it so that the tab key changes edit box focus? DialogBox() does it fine, but switching to CreateDialog() doesn't make that work anymore.