Hover buttons

, and is a varation on Guy Gascoigne’s CTrackLookButton class.

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.

  1. Add 4 owner drawn buttons to a dialog, labelling each with text labels (if required).
  2. Use classwizard to add CButton member variables.
  3. In your dialog’s header file, change the class type from CButton to CHoverButton.
  4. Add the HoverButton.cpp and HoverButton.h source files to your project.
  5. #include “HoverButton.h” in the dialog’s header file.
  6. Design: up, down, focussed and disabled bitmaps for each button, or one set for all buttons (see my example).
  7. Use class wizard to add OnInitDialog() to your dialog’s source file.
  8. In OnInitDialog(), for each button, call LoadBitmaps() passing the bitmap ID’s required for each button.
  9. Add handler functions for BN_CLICKED for each button and add your processing in these functions.
  10. 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.
  11. Call this function after LoadBitmaps(), in your OnInitDialog() function.
  12. Call this function in each of the BN_CLICKED button handler functions.

Downloads

hover_button_src.zip

Source for updated Hoverbutton with bug fixes

  1. Greyed bitmap displayed properly
  2. Accelerator key added to project for fast exit

hover_button_exe.zip

Compiled release of hover button project

hover_group_src.zip(thanks to Jack van Dijk)

Source if project to demonstrate CObjectArray with Hoverbuttons

hover_group_exe.zip

Compiled executable of hover group project

Posted 7 November 1998.
Last Updated 27 March, 1999

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read