The sample program ALIGN.BP in EXLIB:[908,24] illustrates the use of the various alignment options for text within static and button controls.
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, BS_BOTTOM, BS_VCENTER 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 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 sample program STIMGT.BP in EXLIB:[908,32].
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).