.bmp on CButton

Posted on 1999-07-14
Medium Priority
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?

Question by:dave_p
  • 2

Accepted Solution

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;
   CBitmapButton* bmpbutton = (CBitmapButton*)GetDlgItem

That's All.

Hope this helps.


Author Comment

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


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

Thanks again!

Dave P

Author Comment

ID: 1309998
Thanks! Excellant help.

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Through the video, you can check the migration process of Outlook PST file to PDF. Kernel for Outlook to PDF tool can convert Outlook emails with all attributes like Subject, To, From, Cc, Bcc and other folders such as Inbox, Outbox, Sent Items, Jun…

623 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