My application needs to be a dialog box with an icon, title, minimize button, and the close button in the title bar (no maximize button). It's trivial in MFC, but how would you do it in Win32?
What I did was to create an invisible application, and SendMessage to pop up a dialogbox, but I realize that I couldn't add the icon! And when I minimize the dialogbox, it doesn't minimize to the windows task bar. It's definitely a wrong approach. I am such a newbie in Win32 (or even win programming!).
Thanks in advance,
Grace
usman999_1
August 12th, 2004, 04:16 PM
When you create you dialogbox (using DialogBox or CreateDialog) give either of these APIs GetDeskTopWindow() as the handle of the ParentWindow. The dialog will minimise properly etc etc.
HTH,
Regards,
Usman.
Bond
August 12th, 2004, 04:43 PM
For a modal dialog:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pCmdLine, int iCmdShow)
{
return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DialogProc);
}
It depends on what you want to do. You would go for a modal dialog when you popup the dialog for a reason where the user cannot proceed without entering something or cancelling it out. That is the user will not be able to interact with the other parts of the UI.
That is not the case with modeless dialogs. These kind will allow user to switch to other windows and do something.
So, whether you want modal or modeless is driven by your requirements.
Bond
August 13th, 2004, 02:40 PM
There are also cases where you may want to hide your main application window. For example, if you write a tray application, you'll need a dialog or window procedure to process your tray messages. However, you won't want your application window to be onscreen the entire time. So, you can create a modeless dialog and just hide it, only making it visible when the user requests it.
srq70
August 14th, 2004, 02:24 PM
Also, if you want to handle arrow keys, WM_KEYDOWN, etc, I think, it is easier
with modeless dialog, with modal, because these are "DialogMessages" , you
can't get them in DialogProc.
Grace
October 5th, 2004, 05:03 PM
Hi Bond,
I did a modeless dialogbox as you suggested earlier. I also set the Icon inside WM_INITDIALOG by using
The icon is shown on the task bar as well as on the title bar, but the problem is that in the IExplorer, it is still using the default icon. How would you fix this problem?
Thanks,
Grace
For a modeless dialog:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pCmdLine, int iCmdShow)
{
HWND hwnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DialogProc);
MSG msg;
while (GetMessage(&msg, hwnd, 0, 0))
{
if (!IsDialogMessage(hwnd, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
The icon is shown on the task bar as well as on the title bar, but the problem is that in the IExplorer, it is still using the default icon. How would you fix this problem?
Thanks,
Grace
What do you mean "IExplorer?" I assume you're not talking about Internet Explorer. Do you mean Windows Explorer? Or are you talking about the desktop icon?
I think your SetClassLong messages do the same thing, but I've always used:
I figured it out. the ICON resource has to be the lowest number possible in order to show up in the Windows Explorer. I have it set to 2, and it works.
Thanks Bond. :thumb:
Grace
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.