Proper way to end a dialogbox.
Howdy. I'm wondering if I am closing my dialogbox properly. As you can see in my WinMain function, my DialogBox is the main window, the only window. Heres my WinMain function:
Code:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int nShowCmd)
{
MSG msg;
HWND hWnd;
hWnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_MainDlg), NULL, (DLGPROC)DialogProc);
ShowWindow(hWnd, nShowCmd);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
WSACleanup();
return 0;
}
And here is how I close my dialogbox in my DialogProc function:
Code:
....
case WM_DESTROY:
{
PostQuitMessage(0);
return TRUE;
}
case WM_CLOSE:
{
DestroyWindow(hWnd);
return TRUE;
}
...
Should I use EndDialog? Both work.