Use bitmap on button instead of text
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Use bitmap on button instead of text

Hybrid View

  1. #1
    Join Date
    Sep 2007
    Posts
    78

    Use bitmap on button instead of text

    Hi everyone,

    I'm trying to create a dialog where some of the buttons have pictures on them, rather than plain text.
    Is it possible to do that?
    I notice that under the button's properties, under the "styles" tab there's a checkbox "bitmap".
    I've been googling for a bit now, but I can't seem to find any easy way of setting a bitmap.

    Thank you in advance.

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,094

    Re: Use bitmap on button instead of text

    Quote Originally Posted by rmirani View Post
    Hi everyone,

    I'm trying to create a dialog where some of the buttons have pictures on them, rather than plain text.
    Is it possible to do that?
    I notice that under the button's properties, under the "styles" tab there's a checkbox "bitmap".
    I've been googling for a bit now, but I can't seem to find any easy way of setting a bitmap.

    Thank you in advance.
    http://msdn.microsoft.com/en-us/library/a3y45xs0.aspx

    http://msdn.microsoft.com/en-us/library/a1446sbt.aspx
    Last edited by GCDEF; December 15th, 2013 at 08:32 PM.

  3. #3
    Join Date
    Sep 2007
    Posts
    78

    Re: Use bitmap on button instead of text

    Ok, I've tried that with

    Code:
    m_bitmap.LoadBitmap(IDB_BITMAP);
    CButton* pButton = (CButton*)GetDlgItem(IDC_BUTTON1);
    pButton->ModifyStyle(0,BS_BITMAP); 
    pButton->SetBitmap((HBITMAP)m_bitmap);
    It works fine.
    However, the only way to load the bitmap is by importing it through with Insert->Resource.
    In the import process the bmp file is converted to a 4bit bitmap, which is ... kind of retro.
    Is there some way of displaying a 24bit bitmap on the button?

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,976

    Re: Use bitmap on button instead of text

    Quote Originally Posted by rmirani View Post
    However, the only way to load the bitmap is by importing it through with Insert->Resource.
    LoadImage function
    Best regards,
    Igor

  5. #5
    Join Date
    Dec 2013
    Posts
    1

    Re: Use bitmap on button instead of text

    ResourceView->Right Click on Bitmap using Bitmap Editor change color->24
    Height=32
    Width=32

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center