现在的位置: 首页 > 综合 > 正文

DialogResult::O报错

2013年09月13日 ⁄ 综合 ⁄ 共 1162字 ⁄ 字号 评论关闭

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^ e)
{
OpenFileDialog
^openFileDialog1=gcnew OpenFileDialog;
             openFileDialog1
->InitialDirectory="C://";
                  openFileDialog1
->Filter="All files (*.*)|*.*";
             openFileDialog1
->FilterIndex=2;
             openFileDialog1
->RestoreDirectory=true;
                
if(openFileDialog1->ShowDialog()==DialogResult::OK)
             {
                String
^ temp=openFileDialog1->FileName->ToString();
                    originalimage
=Bitmap::FromFile(temp,true);
                Image
^ ithumbnail=originalimage->GetThumbnailImage(250,250,NULL,System::IntPtr(NULL));
                pictureBox1
->Image=ithumbnail;
                button2
->Enabled=true;
             }
         }

 

错误提示如下:
1>d:/projects/add/add/Form1.h(122) : error C2039: 'OK' : is not a member of 'System::Windows::Forms::Form::DialogResult'
1>        d:/projects/add/add/Form1.h(22) : see declaration of 'System::Windows::Forms::Form::DialogResult'
1>d:/projects/add/add/Form1.h(122) : error C2065: 'OK' : undeclared identifier

 

 

解决办法:

openFileDialog1->ShowDialog()==System::Windows::Forms::DialogResult::OK)

 

原因:

Because DialogResult is a existing member of the Form.

抱歉!评论已关闭.