Answer the question
In order to leave comments, you need to log in
How to display an image on a form in an MFC application?
Good afternoon.
There is an MFC project in VS6. You can't upgrade to a more recent VS. It is necessary to load an image in png or bmp from the file system and display it on the form. There is no CImage class in VS6. All I could find was loading bmp from program resources, and I have an external file. Please let me know how to do this seemingly simple task.
Thank you.
Answer the question
In order to leave comments, you need to log in
Here's a finished crutch on pure WinApi.
in the process, Eugene found a shorter solution:
OnInitDialog()
{
CDialog::OnInitDialog();
HBITMAP hBitMap = (HBITMAP)::LoadImage(0, FileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
CStatic* m_picture = (CStatic *)GetDlgItem(IDC_QRIMAGE);
m_picture->ModifyStyle(0xF, SS_BITMAP, SWP_NOSIZE);
m_picture->SetBitmap(hBitMap);
}
Armenian Radio Today, with a fresh mind, I found a fairly short and working solution
OnInitDialog()
{
CDialog::OnInitDialog();
HBITMAP hBitMap = (HBITMAP)::LoadImage(0, FileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
CStatic* m_picture = (CStatic *)GetDlgItem(IDC_QRIMAGE);
m_picture->ModifyStyle(0xF, SS_BITMAP, SWP_NOSIZE);
m_picture->SetBitmap(hBitMap);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question