Solved

loading bitmap in SDI application

Posted on 2003-11-13
6
381 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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 Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need some help with listview limit text 20 111
how to understand recursion 12 229
IdTelnet1DataAvailable handler freezes the Application 4 84
c++ syntax question 9 52
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

856 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