VC中一个关于MessageBox()的问题...

mfklqgah 2008-04-16 11:07:47
如下代码:
int i = MessageBox("....","...",MB_OKCANCEL);
if( i==1)//当按下确认键后MessageBox()的返回值为 1 ,按取消键为 2.
{
CDialog::OnCancel;
}
请问各位高手,还有没有其它更好的方法可以取到MessageBox()的返回值呀
...全文
150 点赞 收藏 11
写回复
11 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
casinosun 2008-04-17
除非你自己写一个messagebox的程序,网上也有很多
回复
xjchilli 2008-04-17
这样直接不就OK啦,不要钻牛角了。。。
if( MessageBox( "hello" ) == IDOK )
{
///做该做的事
}
回复
misssir 2008-04-17
组态程序
回复
Ethan_yushui213 2008-04-17
怎么样可以不用编程就自己出来可执行程序呀~~~~~~~~~~~~~~~~


跟上面这个问题差不多
回复
scq2099yt 2008-04-16
这样取就可以了
回复
china_bai 2008-04-16
[Quote=引用 2 楼 wflishh 的回复:]
这样多累呀。不般都是用MessageBox("....","...",MB_OKCANCEL)==IDOK;
If a message box has a Cancel button, the function returns the IDCANCEL value if either the ESC key is pressed or the Cancel button is selected. If the message box has no Cancel button, pressing ESC has no effect. 

If the function fails, the return value is zero. To get extended error information, call GetLastError. 


[/Quote]

利用IDOK等常量定义代替返回值。

再应该没其他的办法了。
回复
yanglovexian 2008-04-16
Zero indicates that there is not enough memory to create the message box.

Upon success, one of the values described in the following table is returned.

Value Description
IDABORT Abort button was selected.
IDCANCEL Cancel button or the close button on the title bar was selected.
IDIGNORE Ignore button was selected.
IDNO No button was selected.
IDOK OK button was selected.
IDRETRY Retry button was selected.
IDYES Yes button was selected.
回复
m_nNightmire 2008-04-16
if( MessageBox("....","...",MB_OKCANCEL) == IDOK )
{
blablalba....
}
if( MessageBox("....","...",MB_OKCANCEL) == IDCANCEL )
{
blablalba....
}
回复
shakaqrj 2008-04-16
IDABORT Abort button was selected.
IDCANCEL Cancel button was selected.
IDCONTINUE Continue button was selected.
IDIGNORE Ignore button was selected.
IDNO No button was selected.
IDOK OK button was selected.
IDRETRY Retry button was selected.
IDTRYAGAIN Try Again button was selected.
IDYES Yes button was selected.
回复
wflishh 2008-04-16
这样多累呀。不般都是用MessageBox("....","...",MB_OKCANCEL)==IDOK;
If a message box has a Cancel button, the function returns the IDCANCEL value if either the ESC key is pressed or the Cancel button is selected. If the message box has no Cancel button, pressing ESC has no effect.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

If the function succeeds, the return value is one of the following menu-item values.


IDABORT Abort button was selected.
IDCANCEL Cancel button was selected.
IDCONTINUE Continue button was selected.
IDIGNORE Ignore button was selected.
IDNO No button was selected.
IDOK OK button was selected.
IDRETRY Retry button was selected.
IDTRYAGAIN Try Again button was selected.
IDYES Yes button was selected.
回复
erdgzw 2008-04-16
你想怎样取得返回值呢?
回复
相关推荐
发帖
VC/MFC
创建于2007-09-28

1.5w+

社区成员

VC/MFC相关问题讨论
申请成为版主
帖子事件
创建了帖子
2008-04-16 11:07
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……