...

View Full Version : Dialog Box / C++ Failure to Respond



Dunna
02-19-2005, 12:08 AM
Does anyone know why the following code fails to respond to the user? I mean, the dialog box shows up, but when you click on anything, nothing happens! All help appreciated :)
~dunna



#include <windows.h>
#include <stdio.h>
#include "resource.h"

HWND g_hWnd;
char g_szClass[] = "This wont work";

LRESULT CALLBACK WindowProc1(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg) {
case WM_COMMAND:

switch(LOWORD(wParam)) {

case IDC_CANCEL:
EndDialog(g_hWnd, 0);
break;

default:
break;

}
break;

case WM_CREATE:
break;


case WM_DESTROY:
PostQuitMessage(0);
break;

default: return DefWindowProc(hWnd, uMsg, wParam, lParam);
}

return 0;
}

int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR szCmdLine, int nCmdShow)
{
WNDCLASS wc;
MSG Msg;

wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc1;
wc.cbClsExtra = 0;
wc.cbWndExtra = DLGWINDOWEXTRA;
wc.hInstance = hInst;
wc.hIcon = LoadIcon(hInst, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClass;
RegisterClass(&wc);

g_hWnd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_OPTIONS), 0, NULL);
UpdateWindow(g_hWnd);
ShowWindow(g_hWnd, nCmdShow);


while(GetMessage(&Msg,NULL,0,0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}

UnregisterClass(g_szClass, hInst);

return 0;
}

aman
02-19-2005, 02:23 AM
This will help. http://winprog.org/tutorial/

Dunna
02-19-2005, 02:31 PM
Ahh.....Excellent! Just what I've been loking for! I downloaded the whole thing to my hard drive for offline browsing. Thank you aman! :thumbsup: :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum