CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 1999
    Location
    Slovakia, Austria
    Posts
    159

    How to set bitmap on button?

    I created a dialog with a button and bitmap. I need to give a bitmap on the button. How?

    Who is Man++?
    Click on http:\\lichner.szm.com

  2. #2
    Guest

    Re: How to set bitmap on button?

    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().



  3. #3
    Join Date
    May 1999
    Location
    Spain
    Posts
    335

    Re: How to set bitmap on button?

    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/informati...BUG/avalon.htm



  4. #4
    Guest

    Re: How to set bitmap on button?

    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);






  5. #5
    Join Date
    May 1999
    Location
    CA, USA
    Posts
    586

    Re: How to set bitmap on button?

    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/
    [email protected]

  6. #6
    Guest

    Re: How to set bitmap on button?

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured