关于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;
}