Link to home
Start Free TrialLog in
Avatar of cancermcs
cancermcs

asked on

loading bitmap in SDI application

Hello
how can i load bitmaps directly on screen in an SDI application(FormView) class?I have to load bitmap from any drive in My computer without selecting from dialog.

cancermcs
Avatar of AlexFM
AlexFM

1) Add static control with SS_BITMAP style to the FormView dialog template
2) Load required bitmat using LoadImage API with LR_LOADFROMFILE flag. It returns HBITMAP handle.
3) Set this handle to static control using CStatic::SetBitmap function.
Avatar of cancermcs

ASKER

Hi AlexFM
here i did the work...I have a my class name CMyPicture who set the coordinates of bitmap.objvalue is the value comming from table whose required bitmap has to be loaded.but on line  showing ***,a debug eror comes out.
what should i do for it.
here is code:
protected:
           CMyPicture m_ctrlBmpDig;
public:
         CBitmap* m_pBmp1;
               CString m_strBmpFileOb;

void CPPCView::OnLoadIndexBitmap(CString objvalue)
{


      m_strBmpFileOb = "C:\\Object\\";
      m_strBmpFileOb += objvalue;
      m_strBmpFileOb += ".bmp";

      if(!m_strBmpFileOb.IsEmpty())
      {
      

            m_pBmp1 = new CBitmap();      
            HBITMAP hBitmap = (HBITMAP)LoadImage(AfxGetApp()->m_hInstance,m_strBmpFileOb,IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);

            if(hBitmap)
      m_pBmp1->Attach(hBitmap);
               
**       m_ctrlBmpDig.SetBitmap(m_pBmp1);
                                                m_ctrlBmpDig.SetWindowPos(NULL,ptB.x,ptB.y,10,10,SWP_SHOWWINDOW);
          m_ctrlBmpDig.ShowWindow (SW_SHOW);}
                  
}
cancermcs
Try:

m_ctrlBmpDig.SetBitmap((HBITMAP)m_pBmp1->m_hObject );
i tried it...Similarly i have tried the Example given in MSDN 2000 (in BitBlt) function but its not working...I must also tell u that i have already a device context(.bmp) running in my application over whom i have to show these other bitmaps.,,whats the solution now.
thanks
cancermcs
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

PAQ with points refunded

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial