whisd@sersun1.essex.ac.uk (Whiteside S D B) (05/07/91)
Can anyone suggest an easy way to get Bitmaps onto buttons, like the WhiteWater resource kit does? Petzold writes his own button but it would have do to its own flashing etc.. Is there any way of putting a bitmap on the standard windows buttons? Thanks!
cms2839@isc.rit.edu (a.stranger) (05/08/91)
In article <5105@servax0.essex.ac.uk> whisd@essex.ac.uk (Whiteside S D B) writes: >Can anyone suggest an easy way to get Bitmaps onto buttons, like the WhiteWater resource kit does? > >Is there any way of putting a bitmap on the standard windows buttons? you use a button of class owner_draw , and you'll need to respond to messages about repainting and state changes . it's all documented . -- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ "Imagination keeps the shadows away - Xymox @ @~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~@ @ a.stranger - CMS2839@ritvax.isc.rit.edu @
bonneau@hyper.hyper.com (Paul Bonneau) (05/08/91)
In article <5105@servax0.essex.ac.uk> whisd@essex.ac.uk (Whiteside S D B) writes: >Can anyone suggest an easy way to get Bitmaps onto buttons, like the WhiteWater resource kit does? > >Petzold writes his own button but it would have do to its own flashing etc.. > >Is there any way of putting a bitmap on the standard windows buttons? > >Thanks! > Use the BS_OWNERDRAW style for the button (in the dialog template if it's in a dialog, or as an argument to CreateWindow(ex) if not). Then be prepared to handle the following messages to paint the button: BN_PAINT BN_HILITE BN_UNHILITE Unfortunately, these messages are missing from Chapter 6 of "Reference - Volume 1". If I remember correctly, BN_PAINT means perform an entire paint of the button, BN_HILITE is sent while the button is being depressed, and BN_UNHILITE after is has been released. I think wParam contains the hdc to paint into, but you should verify this (use the debugger and set a breakpoint of the parent's windowproc to take a look at the parameters). cheers - Paul Bonneau.
whisd@sersun1.essex.ac.uk (Whiteside S D B) (05/13/91)
Many thanks to all who replied to my recent query regarding putting bitmaps on buttons. I've managed to do this thanks to their help! One way to do this is: i) Create the button with the style WS_OWNERDRAW, which means you have to draw the item ii) The window procedure associated with the button (or the dialog box function of the dialog with the control in) will receive 3 kinds of message which it will have to deal with: Each message is of type WM_DRAWITEM. This message has the following components: wParam - child control ID lParam - long pointer to DRAWITEMSTRUCT It's the DRAWITEMSTRUCT that tells you what to do. When the control needs to be first drawn the itemAction field of the structure contains ODA_DRAWENTIRE. When the control is pushed the itemAction is ODA_SELECT and the is also received when the button is released. I keep a BOOL variable to alternate two bitmaps: one for button up, one for button down. When focus is given to the button itemAction is ODA_FOCUS Also in the structure you get: the button window handle, a device context and a rectangle structure showing the size of the button. I used LoadBitmap to get a handle to the bitmap and called Petzold's DrawBitmap() function to put it into the device context. Remember to delete the bitmap once you've done this. (The bitmap is selected into a memory device context, thence into the actual device context by DrawBitmap, so it's okay to delete the bitmap). I use C++ so for speed I load the bitmaps in the class constructor and delete them in the class destructor. I hope this info (which isn't all in one place in the literature I've got) helps others make a very pretty interface! Simon Whiteside