关于DialogBoxParam()的问题,谢谢

niubuer 2007-09-17 03:26:48
当调用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;
}
...全文
862 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
lyg_zy 2007-09-19
  • 打赏
  • 举报
回复
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;


lyg_zy 2007-09-19
  • 打赏
  • 举报
回复
BOOL CALLBACK CMpsdProperties::ParentDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
这个函数应该
return false;
niubuer 2007-09-19
  • 打赏
  • 举报
回复
不知道我描述清楚了没!
niubuer 2007-09-19
  • 打赏
  • 举报
回复
大哥,强的,现在窗口正常很多了!可能窗口属性还有点问题,接下来的我再慢慢调好了!
niubuer 2007-09-18
  • 打赏
  • 举报
回复
1.GetInstance()保证是正确的; 2.将 DefWindowProc(hWnd, message, wParam, lParam);注释掉效果一样; 3.IDD_PROPERTIES_PARENT 资源正确,rc中窗口属性为: STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU; resource.h中: #define IDD_PROPERTIES_PARENT 133

窗口轮廓\窗体上的控件 能显示出来,但客户区的其他区域就不能正确显示; 而且即使能点中窗口caption栏,也不能拖动窗口.
谢谢
菜牛 2007-09-17
  • 打赏
  • 举报
回复
GetInstance()不知道是否正确。
flyelf 2007-09-17
  • 打赏
  • 举报
回复
default: return 0;
Yofoo 2007-09-17
  • 打赏
  • 举报
回复
查查资源 IDD_PROPERTIES_PARENT 是否正常

15,978

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧