2010年6月19日 星期六

C+ OpenFileDialog Example

OpenFileDialog^ fDialog = gcnew OpenFileDialog();


if(fDialog->ShowDialog()==System::Windows::Forms::DialogResult::OK){

To_string(fDialog->FileName,fileName1);

}

System::String -> std::string

fucking droublesome!!!!
spend me more than 1hour !!!

buddy can check here , a good way to convert :http://blogs.msdn.com/b/slippman/archive/2004/06/02/147090.aspx


bool To_CharStar( String^ source, char*& target )

{

int len = (( source->Length+1) * 2);

target = new char[ len ];

pin_ptr wch = PtrToStringChars( source );

return wcstombs( target, wch, len ) != -1;

}



bool To_string( String^ source, string &target )

{

int len = (( source->Length+1) * 2);

char *ch = new char[ len ];

bool result ;

{

pin_ptr wch = PtrToStringChars( source );

result = wcstombs( ch, wch, len ) != -1;

}

target = ch;

delete ch;

return result;

}

2010年6月4日 星期五

C# PictureBox with Image class

            Image ig = Image.FromFile("G:\\C++pj\\testImage\\testImage\\figure1.jpg");
           
           

            this.pictureBox1 = new System.Windows.Forms.PictureBox();
            this.pictureBox1.Image = ig;