MessageBox()中如何指定其第一个参数hWnd,而将其设为有模对话框?

mlm18 2003-10-09 11:20:32
如何将MessageBox()产生的对话框变为有模的?如果它的第一个参数是NULL,则对话框是无模的
...全文
112 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
alon21 2003-10-09
  • 打赏
  • 举报
回复
你要的效果,吃饭去了,来晚了一步 :(
::MessageBox(::AfxGetApp()->GetMainWnd()->m_hWnd,"HEllo","Caption",MB_OK);
mlm18 2003-10-09
  • 打赏
  • 举报
回复
谢谢楼上的高手,解决了,给分了
wangjs720 2003-10-09
  • 打赏
  • 举报
回复
设为NULL不就行了?
findcsdn 2003-10-09
  • 打赏
  • 举报
回复
用这个应该可以:

::AfxGetApp()->GetMainWnd()->m_hWnd
mlm18 2003-10-09
  • 打赏
  • 举报
回复
不好意思,我说的是全局函数::int MessageBox(
HWND hWnd, // handle to owner window
LPCTSTR lpText, // text in message box
LPCTSTR lpCaption, // message box title
UINT uType // message box style
);
mlm18 2003-10-09
  • 打赏
  • 举报
回复
换句话说如何得到当前窗口的句柄
alon21 2003-10-09
  • 打赏
  • 举报
回复
//MessageBox和AfxMessageBox的使用
//Alon
MessageBox函数来自CWnd类,所以只能在从CWnd继承的类( 如CView )中调用它。
AfxMessageBox函数可以在任何地方调用它。

例:
AfxMessageBox("HELLO",MB_ICONSTOP|MB_YESNOCANCEL);
MessageBox("你好!","标题",MB_ICONSTOP|MB_YESNOCANCEL);

参数说明
Message_Box Types
MB_ABORTRETRYIGNORE The message box contains three pushbuttons: Abort, Retry, and Ignore.
MB_OK The message box contains one pushbutton: OK.
MB_OKCANCEL The message box contains two pushbuttons: OK and Cancel.
MB_RETRYCANCEL The message box contains two pushbuttons: Retry and Cancel.
MB_YESNO The message box contains two pushbuttons: Yes and No.
MB_YESNOCANCEL The message box contains three pushbuttons: Yes, No, and Cancel.

Message-Box Modality
MB_APPLMODAL The user must respond to the message box before continuing work in the current window.
However, the user can move to the windows of other applications and work in those windows.
The default is MB_APPLMODAL if neither MB_SYSTEMMODAL nor MB_TASKMODAL is specified.
MB_SYSTEMMODAL All applications are suspended until the user responds to the message box.
System-modal message boxes are used to notify the user of serious, potentially damaging errors that
require immediate attention and should be used sparingly.
MB_TASKMODAL Similar to MB_APPLMODAL, but not useful within a Microsoft Foundation class application.
This flag is reserved for a calling application or library that does not have a window handle available.

Message-Box Icons
MB_ICONEXCLAMATION An exclamation-point icon appears in the message box.
MB_ICONINFORMATION An icon consisting of an “i” in a circle appears in the message box.
MB_ICONQUESTION A question-mark icon appears in the message box.
MB_ICONSTOP A stop-sign icon appears in the message box.

Message-Box Default Buttons
MB_DEFBUTTON1 The first button is the default. Note that the first button is always the default unless MB_DEFBUTTON2 or MB_DEFBUTTON3 is specified.
MB_DEFBUTTON2 The second button is the default.
MB_DEFBUTTON3 The third button is the default.
mlm18 2003-10-09
  • 打赏
  • 举报
回复
我想产生的对话框和AfxMessageBox()产生的一样,但是AfxMessageBox中没法指定对话框的Caption
alon21 2003-10-09
  • 打赏
  • 举报
回复
MessageBox()产生的对话框都是有模的,无模的只能自己建
mlm18 2003-10-09
  • 打赏
  • 举报
回复
有没搞错????
xiaohyy 2003-10-09
  • 打赏
  • 举报
回复
MessageBox()产生的对话框都是有模的

15,979

社区成员

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

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