The following sample program (ALIGN.BP[908,24] in the EXLIB) illustrates the use of the various alignment options for text within static and button controls.
this is a linked image
The tooltip for each control shows details about the ctype and winstyle flags, and of course the source code reveals all, but here are the relevant flags from ctype:
Flag |
Description |
MBF_LFJUST |
Left justify text |
MBF_RTJUST |
Right justify text |
MBF_HCENTER |
Horizontally center text |
MBF_VCENTER |
Vertically center text |
MBF_CENTER |
Vertically and horizontally center text |
BS_TOP (&h00000400), BS_BOTTOM (&H00000800), BS_VCENTER (&h00000C00) can be added to the WINSTYLE parameter for buttons to adjust the vertical alignment of the text within the button. The horizontal alignment can be adjusted by the traditional MBF_RTJUST and MBF_LFJUST flags. Note: default alignment for buttons is centered in both directions.
SS_CENTERIMAGE (&h00000200) can be added to the WINSTYLE parameter for static images (scaled with MBF_NODISTORT and without any other MBF_xxx alignment options) to center them within the static control, without changing the size of the control. See the STIMGT.BP[908,32] sample program.
See Image Control for an example of using these same flags for aligning images within Static Text controls, and see the cstate MBST_?CENTER flags for options relating to centering the control itself (relative to its parent).