gpt4 book ai didi

visual-c++ - 如何从消息框获取答案

转载 作者:行者123 更新时间:2023-12-04 08:12:06 25 4
gpt4 key购买 nike

我复制

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>------ 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 ==========

怎么了?如何解决这个问题?

最佳答案

我很困惑,但是 DialogResult 的 MSDN 文章在 C++ 示例中提到类型名称应以 :: 为前缀以使其成为非嵌套的。也许试试这个:

if (MessageBox::Show(
"Are you sure that you would like to close the form?",
"Form Closing", MessageBoxButtons::YesNo,
MessageBoxIcon::Question) == ::DialogResult::No)

(我还删除了多余的括号......)

如果没有帮助,请尝试指定完整的命名空间,即 ::System::Windows::Forms::DialogResult::No 以查看它是否至少有效。

关于visual-c++ - 如何从消息框获取答案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3776688/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com