Enhanced button control (MC_WC_BUTTON
).
More...
Go to the source code of this file.
Data Structures | |
struct | MC_NMBCDROPDOWN |
Structure for notification MC_BCN_DROPDOWN. More... | |
Defines | |
Window Class | |
#define | MC_WC_BUTTONW L"mCtrl.button" |
Window class name (unicode variant). | |
#define | MC_WC_BUTTONA "mCtrl.button" |
Window class name (ANSI variant). | |
#define | MC_WC_BUTTON MC_WC_BUTTONW |
Unicode-resolution alias. | |
Control Styles | |
#define | MC_BS_SPLITBUTTON (0x0000000CL) |
Style to create a split button. | |
#define | MC_BS_DEFSPLITBUTTON (0x0000000DL) |
Style to create a default split button. | |
Control States | |
#define | MC_BST_DROPDOWNPUSHED 0x0400 |
State of the split button when dropdown button is pressed. | |
Control Notifications | |
#define | MC_BCN_DROPDOWN ((0U-1250U) + 0x0002) |
Notification fired when user clicks on the dropdown button. | |
Functions | |
BOOL MCTRL_API | mcButton_Initialize (void) |
Registers window class of the button control. | |
void MCTRL_API | mcButton_Terminate (void) |
Unregisters window class of the button control. |
Enhanced button control (MC_WC_BUTTON
).
MC_WC_BUTTON
control is subclass of standard BUTTON
class.
In fact, MC_WC_BUTTON
does not provide any new functionality. It only helps to overcome some compatibility limitations between button implementation in various versions of COMCTL32.DLL
.
COMCTL32.DLL
in Windows XP does not implement themed buttons with BS_ICON
style, so the icon button are not consistent with other controls. MC_WC_BUTTON
solves it, see Icon buttons for more info.COMCTL32.DLL
since Windows Vista. Applications wanting to use them on previous versions of Windows have to reimplement them manually - or they now can use MC_WC_BUTTON
instead. See Split buttons for more info.In all other aspects the MC_WC_BUTTON
control behaves as the standard BUTTON
(strictly speaking it inherits those features by subclassing) as available on the Windows version and COMCTL32.DLL
version avaiable on the system where your application runs. So you can use MC_WC_BUTTON
everywhere, instead of all buttons and use the standard flags when creating them, e.g. BS_GROUPBOX
or BS_CHECKBOX
.
On Windows XP, the standard BUTTON
uses the old and boring look from Windows 95/98 when you use style BS_ICON
and set image of the button with BM_SETIMAGE
. If you have enabled the XP theming (as it is by default in Windows XP), then the button simply does not look consistently with other controls in your application.
If you use MC_WC_BUTTON
, the button is styled if XP styles are avaiable and enabled on the system. If your application supports XP theming, you should prefer MC_WC_BUTTON
windows class over BUTTON
for icon buttons.
Comparision of icon button without and with Windows XP Styles:
From developer's point of view, the use of icon button is absolutely the same as the standard BUTTON
control. Use standard BS_ICON
style and BM_SETIMAGE
message.
MC_WC_BUTTON
does not implement support for XP styling of buttons with style BS_BITMAP
. Currently only BS_ICON
is supported. I.e. on Windows XP, the buttons with style BS_BITMAP
still look as if not styled with the XP theme.Split button is a push button devided to two parts. The main part behaves as the normal push buttons and the other part (called dropdown) opens some options closely related with the function of the main button part. In a typical use-case the dropdown launches a popup menu.
To make a split button, just specify style MC_BS_SPLITBUTTON or MC_BS_DEFSPLITBUTTON when you create the control.
To handle clicks on the main part of the button, handle WM_COMMAND
as for any other normal push buttons.
To handle clicks on the dropdown part of the button, handle message WM_NOTIFY
. If the message originates from MC_BS_SPLITBUTTON control, recast LPARAM
to MC_NMBCDROPDOWN* and check if MC_NMBCDROPDOWN::hdr.code
is MC_BST_DROPDOWNPUSHED.
Note that all the mCtrl split button styles and messages supported by MCTRL.DLL
(those defined in this header with the prefix "MC_"
) have values equal to their standard counterparts as defined by Microsoft SDK in <commctrl.h>
so they can be used interchangably. The advamtage of those mCtrl ones is that they are defined always when you include <mCtrl/button.h>
, while the standard identifiers in <commctrl.h>
are defined only if _WIN32_WINNT >= 0x0600
.
MC_WC_BUTTON
implements only subset of styles and messages for split buttons offered on Window Vista.If the Windows support split button in a natural way (Vista or newer), the MC_WC_BUTTON
just simply passes all messages down to the original BUTTON
window procedure. This guarantees good consistency of the control's look and feel with other system controls, but it also brings a minor pitfall for developers: If you use standard identifiers of split button messages and styles (e.g. BS_DEFSPLITBUTTON
instead of MC_BS_DEFSPLITBUTTON) then it is easy to forget about the limitation. It then will work in runtime as intended on Windows Vista or newer but not on the Windows XP or older.
For more information, you can refer to documentation of split buttons on MSDN (but still keep in mind that only some of the features are reimplemented in mCtrl).
#define MC_WC_BUTTON MC_WC_BUTTONW |
Unicode-resolution alias.
#define MC_BS_SPLITBUTTON (0x0000000CL) |
Style to create a split button.
It is equivalent to standard BS_SPLITBUTTON
. It is provided because the standard BS_SPLITBUTTON
is defined only if _WIN32_WINNT >= 0x0600
.
#define MC_BS_DEFSPLITBUTTON (0x0000000DL) |
Style to create a default split button.
It is equivalent to standard BS_DEFSPLITBUTTON
. It is provided because the standard BS_SPLITBUTTON
is defined only if _WIN32_WINNT >= 0x0600
.
#define MC_BST_DROPDOWNPUSHED 0x0400 |
State of the split button when dropdown button is pressed.
It is a possible value returned by standard BM_GETSTATE
message. It is equivalent to standard BST_DROPDOWNPUSHED
. It is provided because the standard BST_DROPDOWNPUSHED
is defined only if _WIN32_WINNT >= 0x0600
.
#define MC_BCN_DROPDOWN ((0U-1250U) + 0x0002) |
Notification fired when user clicks on the dropdown button.
It is equivalent to standard BCN_DROPDOWN
. It is passed via the WM_NOTIFY
message. It is provided because the standard BCN_DROPDOWN
is defined only if _WIN32_WINNT >= 0x0600
.
[in] | wParam | (int ) Id of the control sending the notification. |
[in] | lParam | (MC_NMBCDROPDOWN*) Data associated with the notification. |
BOOL MCTRL_API mcButton_Initialize | ( | void | ) |
Registers window class of the button control.
TRUE
on success, FALSE
on failure. void MCTRL_API mcButton_Terminate | ( | void | ) |
Unregisters window class of the button control.