﻿# Control Alignment

The sample program [ALIGN.BP in EXLIB:\[908,24\]](https://bitbucket.org/microsabio/exlib/src/master/908024/align.bp) illustrates the use of the various alignment options for text within static and button controls.

(./images/ashref_img161.png)

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](ctype.md):

| **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\]](https://bitbucket.org/microsabio/exlib/src/master/908032/stimgt.bp).

See [Image Control](imagecontrol.md) for an example of using these same flags for aligning images within Static Text controls, and see the [cstate](cstate.md) MBST\_?CENTER flags for options relating to centering the control itself (relative to its parent).