tags:

views:

393

answers:

3

hello frnds, I am Trying to add an image to an existing button..I have done that to an extent, the problem is I can add an ownerdrawn Image but am not able to add the extact image that I want.. for the example see the below code

CButton* pBtn= (CButton*)GetDlgItem(ID_WIZBACK);

   pBtn->ModifyStyle( 0, BS_ICON );

   HICON hIcn= (HICON)LoadImage(
        AfxGetApp()->m_hInstance,
  MAKEINTRESOURCE(IDI_ICON3),
        IMAGE_ICON,
        0,0, // use actual size
        LR_DEFAULTCOLOR
    );

    pBtn->SetIcon( hIcn );

with the above code am converting the bitmap to an icon to add to my button...how can I add the exact Bitmap image directly to an existing button.Please help me frnds..

+1  A: 

You could subclass existing button using CBitmapButton::SubclassWindow, then use LoadBitmaps.

Kirill V. Lyadvinsky
A: 

I actually fixed the problem..what I did is I replaced the HICON with HBITMAP and its working perfect...basically both would work fine but in my case when I loaded the icon into the button the background of the icon was not changing...I tried Bitmap then it work great. Now am working on positioning the Image and to add text...think I could go through

kiddo
You can mark this as the answer then.
Kavitesh Singh
A: 

Use the button classes from the Feature Pack. They have support for showing both text and images on buttons, your regular button can't do that. Look at the 'samples' directory in your VS installation directory.

Roel