Virtual Developer Workshop: Containerized Development with Docker
Looking around for some nice bitmap hoverbuttons, I just couldn't find what I was looking for. In this case there are a couple of things you can do:
- Leave it.
- Buy it.
- Steal it.
- Get it for free.
- Start crying
- Do it yourself (and possibly share it.)
I found another hoverbutton class that uses SetCapture() and ReleaseCapture(). Using this method gives earlier or later some problems. I can't remember why, but it did to me. So I thought why do it so diffifcult? MS has a nice API to handle hoverstates: _TrackMouseEvent().
How to use it?
- In you resource editor create a button and set the 'owner draw' property.
- Use classwizard to create a CButton object in your dialog.
- Include the "hoverbutton.h" file in your dialog class file.
- Rename the 'CButton' object type to 'CHoverButton'.
- Create a bitmap with three buttonstates: Up/Down/Hover. The pictures need
to be right next to each other.
The button will calculate it's own size (the width of the bitmap)/3.
You can use true color bimaps here.
- In the OnInitDialog() load the bitmap with mybutton.LoadBitmap(IDC_MYBUTTON);
- Set a tooltip with mybutton.SetToolTipText();
- Compile and watch.