Solved

loading bitmap in SDI application

Posted on 2003-11-13
6
379 Views
Last Modified: 2012-05-04
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
0
Comment
Question by:cancermcs
6 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 9745723
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.
0
 

Author Comment

by:cancermcs
ID: 9762249
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
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 9762271
Try:

m_ctrlBmpDig.SetBitmap((HBITMAP)m_pBmp1->m_hObject );
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:cancermcs
ID: 9776484
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
0
 
LVL 9

Expert Comment

by:tinchos
ID: 10249172
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
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 10308142
PAQed, with points refunded (40)

modulo
Community Support Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now