A Button with Rollover Behavior using C++






1.69/5 (20 votes)
Jan 3, 2003

124761

1667
This class provides a button with rollover behavior
Introduction
CRolloverButton
is a CButton
derived class. It provides a button with rollover behavior known from many webpages. The bitmaps must consist of three pictures for the different states (using the following order normal, rollover, disabled) of the button.
Usage of CRolloverButton
- In your resource editor, create a button (do not set the 'owner draw' property).
- Use
classwizard
to create aCButton
object in your dialog. - Include the "rolloverbutton.h" file in your dialog class file.
- Rename the
CButton
object type toCRolloverButton
. - Call the
SetBitmaps
function in order to assign your bitmap to the new button.
SetBitmaps
CRolloverButton::SetBitmaps(UINT nID, int nWidth, int nHeight, COLORREF crTransparentMask)
nID
- ID of a bitmap resourcenWidth
- Width of one imagenHeight
- Height of your imagecrTransparentMask
- color displayed transparently (normallyRGB(255, 255, 255)
Magenta)
Example
BOOL CButtonTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_btn_OK.SetBitmaps(IDB_BITMAP1, 18, 20, RGB(255, 0, 255));
return TRUE;
}
License
This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below. A list of licenses authors might use can be found here.