Click to See Complete Forum and Search --> : How to set bitmap on button?


Man++
October 1st, 1999, 02:25 AM
I created a dialog with a button and bitmap. I need to give a bitmap on the button. How?

October 1st, 1999, 02:34 AM
Either by using the OWNER_DRAWN - style on the button or -the methode I'd prefer - by using class CBitmapButton. Put a button into your dialog resource, use ClassWizard (Member Variables) to attache the button to a CBitmapButton control and call CBitmapButton's AutoLoad() or LoadBitmaps() in OnInitDialog().

Braulio
October 1st, 1999, 02:41 AM
Hi,

I told you how to put one icon ( for a bitmap is similar you have too look what is the order to load the bitmap form the resource), first put the icon in the resource editor, then in the button properties set the icon checkbox to true ( if it is the bitmap, set the bitmap checkbox), and the in OnInitDialog from your dialog make this:

m_MyButton.SetIcon(AfxGetApp()->LoadIcon(IDI_MYRESOURCEICON);

That's all, if you don't find the information to make with a bitmap, tell it to me, and I will look for it, Good Luck !



Braulio El loco de Alemania...
Málaga - Oehningen - Schaffhausen
Pagina en Español:
http://www.paisvirtual.com/informatica/programacion/THEBUG/avalon.htm

October 1st, 1999, 07:24 AM
Make the text on the button say something like but1
Then make your bitmaps...you can have 4, up, down, inactive, focus
Up is required
if you text is but1 then you would name your bitmap "but1U" for the up state
"but1D" for down, "but1x" for inactive, "but1f" for focus...the quotes should be part of the id.

Then you make your button owner draw,

then create a control variable for you button, CBitmapButton m_ctrlvariable;
then in your initdialog call

m_youctrlvar.AutoLoad(IDC_YOURBUTTON,this);

Rail Jon Rogut
October 1st, 1999, 08:06 AM
Chexk out my Example 12 at http://home.earthlink.net/~railro/mfc_link.html.

Rail

------------
Recording Engineer/Software Developer
Rail Jon Rogut Software
http://home.earthlink.net/~railro/
railro@earthlink.net

October 1st, 1999, 09:24 AM
Check bitmap style in property/style from resource editor
In OnInitDialog() add this code

MyButton = (CButton *) GetDlgItem (IDC_YOURBUTTON_ID);
MyButton->SetBitmap(::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(YOUR_BITMAP_ID)));



hope this helps