DIGIT-ARC read-only archive · snapshot: July 23, 2026

VC++

3 posts · originally from https://geek.digit.in/community/threads/vc.7693/

U
un Original post #1
Mar 31, 2005 at 9:48 AM
How can I make MDI to open graphics images in vc++?

Edit: [enoonmai] Edited to make it more readable.
enoonmai
Mar 31, 2005 at 11:25 AM
First of all, we can read perfectly normal font. There's no need to use size 18 bold red font. :D

Use the FileOpenDialog class this way:
OpenFileDialog *opfdlg=new OpenFileDialog ();
opfdlg->Filter="JPEG files (*.jpg;*.jpeg)|*.jpg;*.jpeg";
opfdlg->ShowDialog()


To show the image, use:
String *s=opfdlg->FileName;
m_bitmap=new Bitmap(s);
Invalidate();


Use the OnPaint handler this way:
Graphics *g=e->Graphics;
g->DrawImage(m_bitmap,this->AutoScrollPosition.X, this->AutoScrollPosition.Y, m_bitmap->Width,m_bitmap->Height);


That's it. You're done.
U
un #3
Apr 5, 2005 at 12:28 PM
I had been using OnFileopen(), But you have mentioned OpenFileDialog how should I use that class?[/b]