Initializing Our Control
_SB_Init
function is called from the WM_CREATE
message of the _SB_WndProc
main window messaging function. It initializes our SimpleButton with some default values: like colors for background and text and others like default font to use. In _SB_Init
we also check the dwStyle
flags passed to the SimpleButton control (via direct call to CreateWindowEx, call to SimpleButtonCreate
or via dialog resource child control creation) and we can override the dwStyle
flags specified and/or force specific flags to be used or excluded (in case the end-user forgot), for example we can set our control to always use WM_CHILD
plus WM_VISIBLE
etc:
We also set some default values for our control's external properties, like standard colors that might be used for text and background when creating our control. So some of the default values we will set for our control's properties are:
Only some of the external properties are shown for brevity, the ones that are shown are define in SimpleButton.inc
as:
For color properties (COLORREF) we make use of a macro called SRGBCOLOR
that is included in SimpleButton.inc
:
Here is our what our SimpleButton control will look like, in the image below, if it is created with the default property values we have assigned to it in our initialization function _SB_Init
:
Note that it doesnt make use of the blue text color and border shown in our earlier image in the Our First Control section.
So by implementing this initialization routine for the end-user, it means they can use the SimpleButton control straight away, or they can choose to modify any of the external properties to customize it to their requirements after the control is created, whichever suits. See the Control Properties section later on for more details.
Last updated