Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

.bmp on CButton

Posted on 1999-07-14
3
Medium Priority
?
537 Views
Last Modified: 2013-11-20
I am developing a MFC app. I have a CButton on a form. I have never done this before, I would like to put a .bmp on a CButton object. I scanned something and have it in .bmp format. A member function on CButton is: SetBitmap which takes a bitmap object. I can't figure out how to get the bitmap object from a .bmp file. Can somebody give me a little step by step on how to do this? Do I have to "import" this .bmp into my resources?

Thanks!
0
Comment
Question by:dave_p
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Accepted Solution

by:
Recez earned 200 total points
ID: 1309996
1. Add the bitmap to your resources using import...
   (if it has more than 256 colors then vc++ won't display
    it, but don't worry.)

2. Under OnInitDialog write:

   //assume the resource ID for your bitmap is IDB_BITMAP:
   //assume your button's ID is IDC_BUTTON:

   CBitmap bmp;
   bmp.LoadBitmap(IDB_BITMAP);
   CBitmapButton* bmpbutton = (CBitmapButton*)GetDlgItem
      (ID_BUTTON);
   bmpbutton->SetBitmap(bmp.m_hObject);

That's All.

Hope this helps.

0
 

Author Comment

by:dave_p
ID: 1309997
Well heck, it didn't display the bitmap. I did what you suggrest except I had
to

m_CB_weldedshock.SetBitmap(HBITMAP(bitMap));

since bitMap.m_hObject wasn't liked by the compiler. I didn't mention it but
I'm using VC++ 4.2 (I have to) so maybe that answers that. Anyway, the
bitmap was imported fine except it looks to be a "negative" of what I
scanned but I will cross that bridge when I get to it. In any event, the
push button just plain does not display the bitmap. What could I be
forgetting?

Thanks again!

Dave P
0
 

Author Comment

by:dave_p
ID: 1309998
Thanks! Excellant help.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

715 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