BOOL CALLBACK WindowProcA(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
HWND hWnd=NULL;
hWnd=CreateDialogParam(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),NULL,WindowProcA,1);
if(hWnd)
MessageBox(NULL,"AAAA",0,0);
ShowWindow(hWnd, SW_SHOWNORMAL);
UpdateWindow(hWnd);
MSG msg;
while(1)
{
if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if(msg.message==WM_QUIT)
break;
IsDialogMessage(hWnd,&msg);
}
}
return int(msg.wParam);
}
BOOL CALLBACK WindowProcA(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:
return 1;
case WM_CLOSE:
DestroyWindow(hWnd);
return 1;
case WM_DESTROY:
PostQuitMessage(0);
return 1;
};
return 0;
}
[/Source]
OMG Help me I cant find the Error
Hi
in WM_INITDIALOG you are returning 1, meaning dialog is trying to set focus to child window(button for example) that is specified in wParam.
If you put there return 0 you are preventing setting of default focus button.
Meaning, if you have invalid handle to default button, it will crash (i.e. trying to set non-existent button to default focus).
Hope this helps.
in WM_INITDIALOG you are returning 1, meaning dialog is trying to set focus to child window(button for example) that is specified in wParam.
If you put there return 0 you are preventing setting of default focus button.
Meaning, if you have invalid handle to default button, it will crash (i.e. trying to set non-existent button to default focus).
Hope this helps.
THank you, I'll try to do something in the WM_INITDIALOG.
I already debug step by step and msg.message=18=WM_QUIT right in the first time it enters the loop
OK I tried , hWnd is always 0 after CreateDialogParam
I try to either set return 0 in WM_INIDIALOG or return 1 and set CreateDialogParam(......, IDC_BUTTON1). Still doesnt work
Any other cases shoud I try
THank you
I try to either set return 0 in WM_INIDIALOG or return 1 and set CreateDialogParam(......, IDC_BUTTON1). Still doesnt work
Any other cases shoud I try
THank you
Even I delete All things and just Put
MessageBox(NULL,"Hello","12234",0);
the Box didnt even show up ,what's wrong
MessageBox(NULL,"Hello","12234",0);
the Box didnt even show up ,what's wrong
One more thing, message pump loop, should look something like this:
but yours is also ok.
If the program doesn't start, then it is possible that program can't initialize some of the controls.
Surely your hWnd didn't initialize normally, it is NULL because CreateDialogParam failed. You can get more information on last error calling GetLastError() function.
while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0) { if (bRet == -1) { // handle the error and possibly exit } else { if(!IsDialogMessage(hWnd,&msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } }
but yours is also ok.
If the program doesn't start, then it is possible that program can't initialize some of the controls.
Surely your hWnd didn't initialize normally, it is NULL because CreateDialogParam failed. You can get more information on last error calling GetLastError() function.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement