CreateDialog problem
Hi guys,
i wrote code which doesn''t work correctly.. the dialog appears but you can''t close it...
i took most of the code from Charles Petzold''s book, but nothing he described about this topic does really work..
here''s the code - can you see what''s wrong?
#include
#include "resource.h"
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
BOOL CALLBACK DlgProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE,LPSTR,int iCmdShow)
{
static char szAppName[] = "pCalc";
HWND hwnd;
MSG msg;
WNDCLASSEX wndclass;
// set up window settings
wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW/CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = DLGWINDOWEXTRA;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
wndclass.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
// register it
RegisterClassEx(&wndclass);
// create and show dialog
hwnd = CreateDialog(hInstance,MAKEINTRESOURCE(pCalc),0,(DLGPROC)DlgProc);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
BOOL CALLBACK DlgProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam)
{
switch(iMsg)
{
case WM_DESTROY:
PostQuitMessage(0);
return FALSE;
}
return FALSE;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam)
{
switch(iMsg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,iMsg,wParam,lParam);
}
Please help me... thanks...!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement