CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 1999
    Location
    Malaysia
    Posts
    99

    Attach BMP to control button

    I am using vc++ 6.0.
    I would like to know how to attach a BMP file to my control button instead of adding text.



    ty

  2. #2
    Join Date
    May 1999
    Location
    Farnborough, Hants, England
    Posts
    710

    Re: Attach BMP to control button

    You need a CBitmapButton.


    --
    Jason Teagle
    [email protected]

  3. #3
    Join Date
    May 1999
    Posts
    12

    Re: Attach BMP to control button

    You set the button's property to Ownerdraw,

    then you can draw the bitmap in the

    OnDraw(or OnButtonDraw.., I forget) function.


  4. #4
    Join Date
    May 1999
    Posts
    40

    Re: Attach BMP to control button

    You can load in the BMP file using ::LoadImage(). This lets you load either a bitmap resource or a .bmp file and get a handle to a bitmap. Pass this handle to the SetBitmap() of the CButton. You also need to set the BS_BITMAP style for the button which you can do in the resource editor. You can also use a CBitmapButton or an owner drawn button but they are a bit more complicated. The disadvantage of using a SetBitmap() is that you only have one bitmap for the button whereas a CBitmapButton lets you specify different bitmaps depending on the state of the button. So for example if you use SetBitmap() for a disabled button it tends to look rather ugly (I have a solution for that but its complicated).

    If you have any questions or need a code sample let me know.

    Josh



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