如何从消息框获取答案
我
if ((MessageBox::Show(
"Are you sure that you would like to close the form?",
"Form Closing", MessageBoxButtons::YesNo,
MessageBoxIcon::Question) == DialogResult::No))
{
// cancel the closure of the form.
Application::Exit();
}
从 msdn 复制。我在哪里编译这个
1>------ 构建开始:项目:test2,配置:调试 Win32 ------ 1>测试2.cpp 1>c:\users\kredkołamacz\documents\visual studio 2010\projects\test2\test2\Form1.h(103): 错误 C2039: '否': 不是 'System::Windows::Forms:: 的成员形式::对话框结果' 1> c:\users\kredkołamacz\documents\visual studio 2010\projects\test2\test2\Form1.h(16) :参见“System::Windows::Forms::Form::DialogResult”的声明 1>c:\users\kredkołamacz\documents\visual studio 2010\projects\test2\test2\Form1.h(103):错误 C2065:“否”:未声明的标识符 ========== 构建:0 成功,1 失败,0 最新,0 跳过 ==========
出了什么问题?如何解决这个问题?
I copy
if ((MessageBox::Show(
"Are you sure that you would like to close the form?",
"Form Closing", MessageBoxButtons::YesNo,
MessageBoxIcon::Question) == DialogResult::No))
{
// cancel the closure of the form.
Application::Exit();
}
From msdn. Where I compiling this i have
1>------ Build started: Project: test2, Configuration: Debug Win32 ------
1> test2.cpp
1>c:\users\kredkołamacz\documents\visual studio 2010\projects\test2\test2\Form1.h(103): error C2039: 'No' : is not a member of 'System::Windows::Forms::Form::DialogResult'
1> c:\users\kredkołamacz\documents\visual studio 2010\projects\test2\test2\Form1.h(16) : see declaration of 'System::Windows::Forms::Form::DialogResult'
1>c:\users\kredkołamacz\documents\visual studio 2010\projects\test2\test2\Form1.h(103): error C2065: 'No' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
What's wrong? How fix this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我很困惑,但 MSDN 文章
DialogResult
在 C++ 示例中提到,类型名称应以::
为前缀,以使其非嵌套。也许可以尝试这个:(我还删除了多余的括号...)
如果没有帮助,请尝试指定完整的命名空间,即
::System::Windows::Forms::DialogResult::No
看看这是否至少有效。I’m stumped but the MSDN article for
DialogResult
mentions in the C++ example that the type name should be prefixed with::
to make it non-nested. Maybe try this:(I also removed the redundant parentheses …)
If it doesn’t help, try specifying the full namespace, i.e.
::System::Windows::Forms::DialogResult::No
to see if that at least works.