Hover buttons | CodeGuru

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. Add 4 owner drawn buttons to a […]

Written By
CodeGuru Staff
CodeGuru Staff
Mar 28, 1999
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

, 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

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.