-
Dailog Tutorials?
Well in my quest to learn Win32, i am going to expand in the realm of dialogs.
I was hoping someone had some good dialog resources, showing many examples.
MSDN helps to an extent, but when i dont know exactly what to do MSDN is mostly just confusing. I'v got a decent grasp of win32, and the standard windows, now i am desiring to learn about Dialog more extensivly and widely then i can find.
Examples i would be looking for are such as:
1.) Creating a Dialog as the main window,
2.) Creating multiple dialogs for multiple options, similar to Winamps multiple windows,
And many examples of Styles and other stuff along that line.
Thanks to any replies! In regards to #1, i was able to do it but aparently i am missing some main system closer because when i close it, windows (or more specifically dev c++, so i assume windows saw it, i forgot to look :p) see's it as still running. Even though i closed the dialog aparently i never sent a main windows closing procedure message?
Anyway, thanks!
-
http://winprog.org/tutorials
Read the stuff on dialogs there and MSND should seem like heaven.
And as to your first question, there are two main ways to use a dialog as your main window. The first is as follows.
Code:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdShow, int nCmdShow)
{
return DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(dialog ID), NULL, dialog's procedure);
}
Very basic. As soon as your dialog closes, out application ends. personally, I prefer the other way, since I have had problems with giving the program an icon using this method. The other is this.
Code:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdShow, int nCmdShow)
{
MSG Msg;
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(dialog ID), NULL, dialog's procedure);
while(GetMessage(&Msg, NULL, 0, 0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
My guess is that you are using this method, but not doing this next step. You MUST have this next case in your Dialog's procedure.
Code:
case WM_CLOSE:
{
EndDialog(hwnd, 0);
PostQuitMessage(0);
}
break;
It's the PostQuitMessage line that actually ends your entire program. Without this, your dialog closes, but your program is still running, doing nothing. In fact, if you are using Windows XP, you can press Ctrl+Alt+Delete and click on the Processes tab and you'll be able to find your program listed there. You can end it from there, but otherwise, it will keep on running until it recieves a QuitMessage, which will never happen if you don't put it in your code.