dialog proc的返回值(TRUE),会引发界面显示出错

来源:互联网 发布:l360清零软件下载 编辑:程序博客网 时间:2024/06/06 21:37

当调用DialogBoxParam()的时候,窗口就是没法正确显示.窗口处理函数中的GetLastError()没提示出错,但Show()函数里的GetLastError()提示错误号为87(参数不正确),实在搞不明白了,我的参数都没问题的啊!   谢谢

int   CMpsdProperties::Show()
{
                  int   result   =   0;
//Do   the   dialog   box
result   =   (int)DialogBoxParam(GetInstance(),
MAKEINTRESOURCE(IDD_PROPERTIES_PARENT),NULL,                           (DLGPROC)       ParentDlgProc,(LONG)   this);

                  DWORD   err   =   GetLastError();

return   1;
}

//窗口处理函数
BOOL   CALLBACK   CMpsdProperties::ParentDlgProc(HWND   hWnd,   UINT   message,   WPARAM   wParam,   LPARAM   lParam)
{
CMpsdProperties   *   _this   =   (CMpsdProperties   *)   GetWindowLong(hWnd,   GWL_USERDATA);

RECT   rc;
int   nScreenWidth,nScreenHeight;
int   wndWidth,wndHeight;
DWORD   err;
switch   (message)
{
case   WM_INITDIALOG:

//   Retrieve   the   Dialog   box   parameter   and   use   it   as   a   pointer   to   the   calling   vncProperties   object
SetWindowLong(hWnd,   GWL_USERDATA,   lParam);
_this   =   (CMpsdProperties   *)   lParam;  

//   Set   the   dialog   box 's   title   to   indicate   which   Properties   we 're   editting
SetWindowText(hWnd,   "播放器:   播放参数 ");
nScreenWidth     =   GetSystemMetrics(SM_CXSCREEN);
nScreenHeight   =   GetSystemMetrics(SM_CYSCREEN);

GetWindowRect(hWnd,&rc);
wndWidth   =   rc.right   -   rc.left;
wndHeight   =   rc.bottom   -   rc.top;
rc.left   =   (nScreenWidth   -   (rc.right   -   rc.left))/2;
rc.top   =   (nScreenHeight   -   (rc.bottom   -   rc.top))/2;
bRes   =   MoveWindow(hWnd,rc.left,rc.top,   wndWidth,wndHeight,FALSE);

ShowWindow(hWnd,SWP_SHOWWINDOW);
err   =   GetLastError();
break;

case   WM_COMMAND:
switch   (LOWORD(wParam))
{
case   IDOK:
case   IDC_APPLY:
case   IDCANCEL:
EndDialog(hWnd,   IDCANCEL);
break;
}
break;
case   WM_CLOSE:
case   WM_DESTROY:
EndDialog(hWnd,IDCANCEL);
break;
default:
DefWindowProc(hWnd,   message,     wParam,     lParam);
break;
}

return   TRUE;
}

 

 

BOOL   CALLBACK   CMpsdProperties::ParentDlgProc(HWND   hWnd,   UINT   message,   WPARAM   wParam,   LPARAM   lParam)
这个函数应该
return   false;

 

DialogProc函数返回值msdn解释:
Typically,   the   dialog   box   procedure   should   return   TRUE   if   it   processed   the   message,   and   FALSE   if   it   did   not.   If   the   dialog   box   procedure   returns   FALSE,   the   dialog   manager   performs   the   default   dialog   operation   in   response   to   the   message. 
 所以,没有处理的消息都应该   return   false;

 

源自:

http://topic.csdn.net/u/20070917/15/19780094-1c3d-486f-9d9a-91063e45e1a0.html?1695638788

原创粉丝点击