非模式创建对话框必须有父窗口的参数吗

zero_226 2012-04-25 11:50:02
从create函数参数上来说是必须有的,但我就是想不通,没有父窗口为什么不能创建对话框。

...全文
94 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
向立天 2012-04-27
  • 打赏
  • 举报
回复
MFC如果为NULL的话实际上就是默认父窗口
zero_226 2012-04-27
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 的回复:]

可以为NULL
[/Quote]
MFC里我没试,但是WTL里是不能为NULL啦,一为NULL,就会跳出父对话框句柄断言失败的提示。
smilenot 2012-04-26
  • 打赏
  • 举报
回复
这个问题可能很多人不知道
坐等高人 回答
诶呦 2012-04-26
  • 打赏
  • 举报
回复
pParentWnd

Points to the parent or owner window object (of type CWnd) to which the dialog object belongs. If it is NULL, the dialog object’s parent window is set to the main application window.

参数可以为NULL,但是具体为什么非要有父窗口,不知道啊,帮顶,学习
向立天 2012-04-26
  • 打赏
  • 举报
回复
可以为NULL
Eleven 2012-04-26
  • 打赏
  • 举报
回复
CDialog::Create()

virtual BOOL Create(
LPCTSTR lpszTemplateName,
CWnd* pParentWnd = NULL
);
virtual BOOL Create(
UINT nIDTemplate,
CWnd* pParentWnd = NULL
);


Parameters
lpszTemplateName
Contains a null-terminated string that is the name of a dialog-box template resource.

pParentWnd
Points to the parent window object (of type CWnd) to which the dialog object belongs. If it is NULL, the dialog object's parent window is set to the main application window.
nIDTemplate
Contains the ID number of a dialog-box template resource.
sunlin7 2012-04-26
  • 打赏
  • 举报
回复
非模式对话框没有独立的消息循环,所以必须有一个父窗口过程来分发非模式对话框的消息。

15,979

社区成员

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

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