WEBINAR: On-demand webcast
How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >
This CHoverButton class is best used in a bank of radio buttons, and behaves like scripted mouse sensitive "pop-up" buttons on web pages.
This article describes how to use this class as a bank of 4 radio buttons.
- Add 4 owner drawn buttons to a dialog, labelling each with text labels (if required).
- Use classwizard to add CButton member variables.
- In your dialog's header file, change the class type from CButton to CHoverButton.
- Add the HoverButton.cpp and HoverButton.h source files to your project.
- #include "HoverButton.h" in the dialog's header file.
- Design: up, down, focussed and disabled bitmaps for each button, or one set for all buttons (see my example).
- Use class wizard to add OnInitDialog() to your dialog's source file.
- In OnInitDialog(), for each button, call LoadBitmaps() passing the bitmap ID's required for each button.
- Add handler functions for BN_CLICKED for each button and add your processing in these functions.
- Add a function to your dialog class to reset all button highlighting to OFF, then set the button which has just been pressed to ON.
- Call this function after LoadBitmaps(), in your OnInitDialog() function.
- Call this function in each of the BN_CLICKED button handler functions.
- Greyed bitmap displayed properly
- Accelerator key added to project for fast exit
Compiled release of hover button project
hover_group_src.zip(thanks to Jack van Dijk)
Source if project to demonstrate CObjectArray with Hoverbuttons
Compiled executable of hover group project
Posted 7 November 1998.
Last Updated 27 March, 1999