How to load jpeg/gif/bmp images to a imagebox when clicking on a listbox
I have a dialogbox with a listbox and image control and couple of textboxes. The listbox lists some image file names from the local hard drive. I need to have the imagebox show the image I click on from listbox. The following code dosen't work. s_pfilelist is aCListBox object and s_pImg is a CImage object.
void CPicExampleView::OnSetfocusFilelist()
{
CString sz;
m_pfilelist.GetText(m_pfilelist.GetCurSel(), sz);
HBITMAP hBitmap=LoadBitmap(AfxGetInstanceHandle(),sz.GetBuffer(100));
CPictureHolder pictholder;
pictholder.CreateFromBitmap(hBitmap);
//Pass dispatch pointer to CPictureHolder
m_pImg.SetPicture(pictholder.GetPictureDispatch());
}
Please help me. Thanks!