Solved

loading bitmap in SDI application

Posted on 2003-11-13
6
377 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

758 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

12 Experts available now in Live!

Get 1:1 Help Now