首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

关于DialogBoxParam()的有关问题,多谢

2012-01-10 
关于DialogBoxParam()的问题,谢谢当调用DialogBoxParam()的时候,窗口就是没法正确显示.窗口处理函数中的Ge

关于DialogBoxParam()的问题,谢谢
当调用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;
}

[解决办法]
查查资源 IDD_PROPERTIES_PARENT 是否正常
[解决办法]
default: return 0;
[解决办法]
GetInstance()不知道是否正确。
[解决办法]
BOOL CALLBACK CMpsdProperties::ParentDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
这个函数应该
return false;

热点排行