开发者

How to get answer from messagebox

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 c开发者_JS百科ompiling 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?


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:

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

(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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜