如何处理用户对消息框的响应? [英] How can I handle the user's response to a message box?
问题描述
我正在编写MFC应用程序.我正在使用消息框向用户显示消息.有没有办法捕获他们的输入,以便我可以对他们做些什么?
例如我有以下代码:
I am writing an MFC application. I am using a Message Box to display messages to the user. Is there a way to capture their inputs so that I can do something with them?
e.g. I have the following code:
MessageBox(L"Do you want to save the changes to this Workspace?", NULL, MB_OK);
如果用户按确定",我想打开一个另存为"对话框.我可以这样做吗?还是我需要在资源编辑器中创建自己的消息框,以便可以为确定"按钮分配唯一的ID,从而处理用户输入?
非常感谢
If the user presses ''OK'' I want to open a SaveAs dialog. Can I do this? Or do I need to create my own message box usin the resource editor so that i can assign a unique ID to the OK button and therefore handle the user input?
Many thanks
推荐答案
您可以使用MB_YESNO
代替MB_OK
并处理消息框的结果,例如:
You could useMB_YESNO
instead ofMB_OK
and handle the result of the messagebox, something like:
if (MessageBox(L"Do you want to save the changes to this Workspace?", NULL, MB_YESNO) == IDYES) /* handle SaveAs dialog */
http://msdn.microsoft.com/en-us/library/ms645505%28v = vs.85%29.aspx [ ^ ]
祝你好运!
http://msdn.microsoft.com/en-us/library/ms645505%28v=vs.85%29.aspx[^]
Good luck!
这篇关于如何处理用户对消息框的响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!