Handling Other Messages For Our Control
Along with handling the WM_CREATE
& WM_NCDESTROY
messages, we have to handle a few more: enabling/disabling our control, setting text, setting fonts, when our control is painted and other features we may wish to include, such as mouse and keyboard interaction (if applicable to our control).
We handle our own painting in our SimpleButton like so with these two messages:
With the above code, we are specifying that we will handle erasing of our control's background ourself and painting of our SimpleButton control via our own paint function _SB_Paint
see Painting Our Control for more details.
We can also allow our SimpleButton control to be enabled or disabled via a standard WM_ENABLE
message, which forces a repaint of our control. And similarly we can allow a font change and repaint via a WM_SETFONT
message.
Our custom messages (SB_GETPROPERTY
,SB_SETPROPERTY
, SB_GETSTATE
and SB_SETSTATE
) are included as well and are just simple calls to our internal helper functions (or framework library if using one):
Other standard messages are used to handle mouse interactions: the mouse moving over our control, leaving it, clicking on it etc via WM_LBUTTONDOWN
, WM_LBUTTONUP
, WM_MOUSEMOVE
, WM_MOUSELEAVE
and other standard win32 api messages.
Last updated