?
Solved

Bitmap Button

Posted on 2003-02-27
3
Medium Priority
?
737 Views
Last Modified: 2013-11-20
hi guys,

can anyone help me with CBitmapButton?

question:
I have a bitmap image which i want to map on to a button in a dialog box. a bitmap image should be displayed on the button instead of text.

thanx for ur help
krithi
0
Comment
Question by:krithi
[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
3 Comments
 
LVL 11

Expert Comment

by:KurtVon
ID: 8037647
I'm not sure what you mean.  Using CBitmapButton on a dialog do the following:

Add the bitmap to your dialog resource.  Make sure it is set to owner draw.

Add the bitmap itself to your resources.

Add the OnInitDialog function and a CBitmapButton object to the dialog object.  In OnInitDialog add

m_cBitmapButton.LoadBitmap(IDC_BUTTON_BITMAP);
m_cBitmapButton.SubclassDlgItem(IDC_BUTTON_ID, this);

If you have the bitmap in a CBitmap, you have to use an owner draw button and draw it yourself.
0
 

Expert Comment

by:zfact
ID: 8040039
Hi Kirthi,

See MSDN. I am pasteing few examples found in the MSDN. Go through it.


-----------------------------------------------------------
//CButton::SetBitmap

Example
CButton myButton;

// Create a bitmap button.
myButton.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_BITMAP,
   CRect(10,10,60,50), pParentWnd, 1);

// Set the bitmap of the button to be the system check mark bitmap.
myButton.SetBitmap( ::LoadBitmap(NULL, MAKEINTRESOURCE(OBM_CHECK)) );
-----------------------------------------------------------

//CButton::GetBitmap

Call this member function to get the handle of a bitmap, previously set with SetBitmap, that is associated with a button.

HBITMAP GetBitmap( ) const;
Return Value
A handle to a bitmap. NULL if no bitmap is previously specified.

Example
CButton myButton;

// Create a bitmap button.
myButton.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_BITMAP,
   CRect(10,10,60,50), pParentWnd, 1);

// If no bitmap is defined for the button, define the bitmap to the
// system close bitmap.
if (myButton.GetBitmap() == NULL)
   myButton.SetBitmap( ::LoadBitmap(NULL, MAKEINTRESOURCE(OBM_CLOSE)) );
----------------------------------------------------------
//CBitmapButton::LoadBitmaps

CBitmapButton myButton;

// Create the bitmap button (must include the BS_OWNERDRAW style).
myButton.Create(NULL, WS_CHILD|WS_VISIBLE|BS_OWNERDRAW,
   CRect(10,10,100,100), pParentWnd, 1);

// Load the bitmaps for this button.
myButton.LoadBitmaps(IDB_UP, IDB_DOWN, IDB_FOCUS, IDB_DISABLE);
-----------------------------------------------------------

Try It, All The Best
Zfact
0
 
LVL 2

Accepted Solution

by:
sreenu_v78 earned 800 total points
ID: 8040890
hai krithi

if u want set bitmap for button change button style BITMAP
create BitMap using resource.

write this code

     CButton *but=(CButton*)GetDlgItem(IDC_BUTTON1);

     CBitmap *bit=new CBitmap;
     bit->LoadBitmap( IDB_BITMAP1);
     
     but->SetBitmap((HBITMAP)bit->m_hObject);


if u want change bitmap dynamically go thru this link what i answer previously..

http://www.experts-exchange.com/Programming/Programming_Languages/MFC/Q_20519121.html

best wishes..
sreenu.

sreenu_v78@yahoo.com

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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 …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses

800 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