⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_35606.htm

📁 一些关于vc的问答
💻 HTM
字号:
<p>
序号:35606 发表者:桎梏 发表日期:2003-04-08 09:28:00
<br>主题:求助:关于MessageBox()返回值的问题?
<br>内容:各位高手:<BR>&nbsp;&nbsp; int save=MessageBox("采集完毕,是否保存采集的数据为文本文件(*.txt)?","数据保存",MB_YESNOCANCEL | MB_ICONEXCLAMATION);<BR>&nbsp;&nbsp;if(save = 1) <BR>&nbsp;&nbsp; { SaveDataAsTxt();&nbsp;&nbsp;} <BR><BR>在MSDN里定义MessageBox为 int型的,我象上面这样做了点‘是’时候调用SaveDataAsTxt();&nbsp;&nbsp; 但是当我点‘否’或者‘取消’也会调用那函数,请问怎么回事啊?又该如何解决? 多谢各位了!<BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:mimibaby 回复日期:2003-04-08 09:53:12
<br>内容:你写错了:if(save = 1) <BR>&nbsp;&nbsp; { SaveDataAsTxt();&nbsp;&nbsp;} <BR>因为if(save = 1) 永远成立应改成:if(save ==1) <BR>&nbsp;&nbsp; <BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:neilgan 回复日期:2003-04-08 09:56:13
<br>内容:Reason: if (save == IDYES) // two '=', not one.<BR>To avoid this kind of bug, always write code this way :<BR>if (IDYES == save)... // put the constant or function return value ( a right value) at the left<BR><BR>And, you never read Msdn???????<BR><BR>Following is what I quoted from Msdn:<BR><BR>The return value is zero if there is not enough memory to create the message box.<BR><BR>If the function succeeds, the return value is one of the following menu-item values returned by the dialog box: <BR><BR>Value Meaning <BR>IDABORT Abort button was selected. <BR>IDCANCEL Cancel button was selected. <BR>IDIGNORE Ignore button was selected. <BR>IDNO No button was selected. <BR>IDOK OK button was selected. <BR>IDRETRY Retry button was selected. <BR>IDYES Yes button was selected. <BR><BR><BR>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. <BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:桎梏 回复日期:2003-04-08 10:44:13
<br>内容:if(save ==1) 这样也不对!<BR>if (save == IDYES)&nbsp;&nbsp;这样就可以了!<BR><BR><BR>多谢两位!<BR>&nbsp;&nbsp; <BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:桎梏 回复日期:2003-04-08 10:45:22
<br>内容:<BR>if(save ==1) 这样也不对!<BR><BR>if (save == IDYES)&nbsp;&nbsp;这样就可以了!<BR><BR>多谢两位!<BR>&nbsp;&nbsp; <BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:mimibaby 回复日期:2003-04-08 11:02:34
<br>内容:给人家分吗?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:桎梏 回复日期:2003-04-08 17:49:06
<br>内容:怎么给分啊?<BR>我接受了他的答案<BR>但是不知道怎么给分哦<BR>请提示<BR>谢谢!<BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -