CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    1

    Setting button bitmaps

    How do you set a bitmap to be the surface of the button using the CButton object? I do not want to use the CBitmapButton class.
    I have tried something like this:

    CBitmap bmp;
    bmp.LoadBitmap(ID_BITMAP1)
    button.SetBitmap((HBITMAP)bmp);

    but I keep getting a run time error (no helpful info in the error).
    I have tried setting the button styles to BS_OWNERDRAW with still no effect.
    Would appreciate any help




  2. #2
    Join Date
    Apr 1999
    Posts
    8

    Re: Setting button bitmaps

    It might be that you have to make the bitmap available to the button after the scope where you set the bitmap runs out. That is, try making bmp a member of your class so it isn't destroyed when your function returns. Otherwise, the bitmap is destroyed and when the button tries to access it(when repainting itself), you get a run time error.

    /Michael Grundberg
    M.Sc. Computer Science
    Visionova IT-System, Sweden
    [email protected]


  3. #3
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: Setting button bitmaps

    Why not use the CBitmapButton class ? It's really very simple.
    It handles the subclassing of the button so that the new drawing
    function is called. It also manages the drawing of the four states
    of a button. The sample CTRLTEST has a good illustration of
    this but it doesn't show all four states of the button (I think).





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