Wednesday, May 22, 2013

Simple Basic Image Viewer Using Visual Studio C++

1. File > New > Project, select Window Forms Application. Enter project Name, browse on where you want to save your project files. Click Ok.
2. Form1 will appear: 
3. On the Properties in right side, change Text Form1 to Open Image.
 4. Select View > Toolbox 
5. Drag and drop button and pictureBox to the form as shown below:
6. On the Properties in right side, change Text button1 to Open Image.

7. On the Properties in right side, change SizeMode Normal to StretchImage.
8. Double-click on Open Image button



9. Copy paste code below as shown below:

OpenFileDialog ^ openFileDialog1 = gcnew OpenFileDialog();
openFileDialog1->Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif";
openFileDialog1->Title = "Select a Image File";
if (openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
pictureBox1->Image=pictureBox1->Image->FromFile(openFileDialog1->FileName);
}

10. Now save and Run file.

No comments:

Post a Comment