CHotButton - a "HotSpot" Button
![]()

CHotButton has two keyboard focus areas, the left text portion and the right hot spot portion. The arrow, tab and shift-tab keys navigate between the two CHotButton areas, behaving like two buttons in that respect.
There are 13 internal hot images, each is shown by calling a corresponding method.
| UseXBitmap() | |
| UseCheckBitmap() | |
| UseFolderBitmap() | |
| UsePaperBitmap() | |
| UsePrinterBitmap() | |
| UseRightArrowBitmap() | |
| UseLeftArrowBitmap() | |
| UseLEDBitmap() | |
| UseEllipseBitmap() | |
| UseBinocularBitmap() | |
| UseClockBitmap() | |
| UseRedFlagBitmap() | |
| UseBannedBitmap() |
Application defined bitmaps
may also be used. They must be provided as a bitmap containing a series of image pairs of two equally sized halves, the left being the active bitmap, the right being the inactive bitmap. For example, a series of one pair would look like this:![]()
The method CHotButton::SetAppBmp(UINT nBitmapID, int cx, COLORREF crMask) installs the application defined bitmap. The parameters are: nBitmapID - the resource ID of the bitmap, cx - the width of a single image (the active or inactive part), and crMask, the transparency color, purple in this case being RGB(255,0,255).
The app may select which application defined pair to use via UseAppBitmap(int iBitmap), where iBitmap is the zero based index of the image pair to use.
A Tooltip may be set for the hotspot via a call to SetTooltipText(LPCSTR szText, BOOL bActivate = TRUE), where szText is the text to display when "hot", and bActivate is the initial activation state. The tooltip may be turned on/off via ActivateTooltip(BOOL bEnable = TRUE).The hot area may be turned on/off via EnableHotSpot(BOOL bEnable = TRUE). When disabled, the inactive bitmap always displays, the tooltip does not show, and the normal BN_CLICKED notification is sent when pressing the button on the hotspot area. The hotspot image area may be hidden/shown via ShowBitmap(BOOL bShow = TRUE), the button looks like a normal button then the hotspot image is hidden.
There are several limitations to the button:
- - only the 3D frame border is supported
- - horizontal center/left/right text is supported, but vertical centering is not
- - multi-line text is not supported
- - the text does not gray out when the WS_DISABLED style is used (this is a TODO, somebody mail me some code!)
In the downloadable source project, HotButton.cpp and HotButton.h are the source code
files, res/HotInternal.bmp is the bitmap for the button's internal images, which should be
mapped to resource ID IDB_HOT_INTERNAL in your own project:
IDB_HOT_INTERNAL BITMAP
DISCARDABLE "res\\HotInternal.bmp"

Comments
EnableWindow not functioning properly
Posted by kberson on 04/03/2004 06:52amIf you EnableWindow(FALSE) the button, the text is not being drawn correctly. The button stops working, but text is not showned greyed out.
Reply