Davide Calabro's CButtonST class port to WTL






4.94/5 (9 votes)
Jun 13, 2001

144420

5210
A fully featured owner-draw button class
Introduction
Now you can use Davide Calabro's excellent CButtonSt
class in your ATL/WTL projects. The Class is still called CButtonSt
and it retains a majority of the original code. Just follow these simple instructions:
- Create a WTL Project
- Design the dialog and add the button controls
- Add the ButtonST.h header file to your project
- Assign a
CButtonSt
to each button. - In
OnInitDialog
,- Subclass each member controls (
CButtonST
) to each ID using theSubclassWindow
method. - uses the
CButtonSt
methods to change the appearance of the control.
- Subclass each member controls (
- In your dialog, don't forget to add the macro
REFLECT_NOTIFICATIONS
which allows the buttons to get messages likeWM_DRAWITEM
.
class MyDialog : public CDialogImpl<MyDialog> { BEGIN_MSG_MAP(MyDialog) ... MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) REFLECT_NOTIFICATIONS() END_MSG_MAP() ... LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); ... CButtonST m_btn; ... }; LRESULT MyDialog::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { ... m_btn.SubclassWindow(GetDlgItem(IDC_BTN)); m_btn.SetIcon(IDI_EOAPP); m_btn.SetFlat(false); ... }
See Davide Calabro's original CButtonSt
article for more details.
Latest Updates
- 26 June 2001
- Updated to Davide Calabro's version 3.2
- Added support for defining the icons from an image list
- Added support for creating dynamically the buttons
- 14 June 2001 - Fixed a bug in the autorepeat feature
Serge Thank you.