I build windows form C++ which it contains one button to open the file then show the file text that I choose on the text box but the issue is the file dialog box not shown no idea why and am sure nothing wrong on my code.
Is something wrong in my setting?
private: System::Void btnOpenImage_Click(System::Object^ sender, System::EventArgs^ e)
{
//Stream;
IO::Stream^ myStream;
OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;
openFileDialog1->InitialDirectory = Directory::GetCurrentDirectory();
openFileDialog1->Filter = "Image Files (JPEG,GIF,BMP,PNG,ICO)|*.jpg;*.jpeg;*.gif;*.bmp;*.png;*ico";
openFileDialog1->FilterIndex = 2;
openFileDialog1->RestoreDirectory = true;
if ( openFileDialog1->ShowDialog() ==System::Windows::Forms::DialogResult::OK)
{
file_path_temp = "image_0003.jpg";
txtImgUrl->Text = file_path_temp;
IntPtr pointer_temp = Marshal::StringToHGlobalAnsi(file_path_temp);
const char* input_location = static_cast<const char*>(pointer_temp.ToPointer());
cv::Mat imgOriginalScene = cv::imread(input_location, CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR);
Marshal::FreeHGlobal(pointer_temp);
}
}