how to load image from file using MFC

Posted by Sweety Khan on Stack Overflow See other posts from Stack Overflow or by Sweety Khan
Published on 2010-06-12T19:04:07Z Indexed on 2010/06/12 19:12 UTC
Read the original article Hit count: 277

Filed under:

**my browse button code is void CFileOpenDlg::OnBnClickedButton1() { // TODO: Add your control notification handler code here CFileDialog dlg(TRUE); int result=dlg.DoModal(); if(result==IDOK) { path=dlg.GetPathName(); UpdateData(FALSE); } } and this is the code for loading an image from resource but tht does not work for loading an image from file. i know LoadImage(); is used for this but how? how can i edit this code to load image from file. Plzz help.....

void CFileOpenDlg::OnBnClickedButton2() { // TODO: Add your control notification handler code here CRect r; CBitmap* m_bitmap; CDC dc, *pDC; BITMAP bmp; m_bitmap = new CBitmap(); m_bitmap->LoadBitmapW(IDB_BITMAP1); m_bitmap->GetBitmap(&bmp); pDC = this->GetDC(); dc.CreateCompatibleDC(pDC); dc.SelectObject(m_bitmap); pDC->BitBlt(200, 200, bmp.bmWidth, bmp.bmHeight, &dc,0 , 0, SRCCOPY); m_bitmap->DeleteObject(); m_bitmap->Detach(); } waiting for reply........**

© Stack Overflow or respective owner

Related posts about c++