Shiny Language Reference
Language Reference > User Interface > Static Text
setstatictextformatting
setstatictextformatting(int ID, dword Style);
Synonyms:
settextformatting(int ID, dword Style);
Sets the alignment style of text in a static text control
The SETSTATICTEXTFORMATTING statement sets the alignment style of a text control previously created with createstatictext. The "alignment style" refers to how the text is displayed within the boundaries of the control, for example whether it is centered horizontally or vertically.
The default formatting style of a new static text control is DT_CENTER, ie: centered horizontally, aligned to the top of the control vertically and with multiple lines of text allowed.
Parameters
ID
The control ID of the button you wish to change the style of
Style
A dword representing the style of the button, as follows. You may combine these values using bitwise OR. These values are defined internally in SSEdit:
DT_TOPAlign text to the top of the control DT_LEFTAlign text to the left of the control DT_CENTERCenter text within the control DT_RIGHTAlign text to the right of the control DT_VCENTERCenter text vertically within the control. This style can only be used when the DT_SINGLELINE style is also specified, ie:
dword Style = DT_VCENTER bitand DT_SINGLELINE; DT_BOTTOMAlign text to the bottom of the control. This style can only be used when the DT_SINGLELINE style is also specified DT_WORDBREAKAutomatically break up the caption text so that each line ends on a word. Without this value Brass will render as many characters as possible into one line, meaning that some words may be wrapped onto 2 lines in the middle of the word. DT_SINGLELINEForce all text to be drawn on a single line, do not wrap any text to a new line. When this style is not specified Brass will assume multi-line text is allowed, including the use of line breaks ("\n") DT_EXPANDTABSExpands tabs ("\t") in the caption text to spaces on-screen. DT_NOCLIPDoesn't clip text to the specified rectangle. DT_NOPREFIXA prefix is an ampersand character (&) followed by any alphanumeric character. This produces the underlines character effect you see in menus, which show the shortcut character. For example, "&Brass" would produce "Brass" on screen. Specifying this style tells Brass to always draw & characters and not to interpret them as shortcut directives. DT_PATH_ELLIPSISWhen the string is too long to fit in the control, Brass will insert 3 full stops into the middle of the string. For example, "This is a very long string" will become "This is ... string". DT_END_ELLIPSISWhen the string is too long to fit in the control, Brass will draw as much text as it can fit, remove the remaining text and replace it with 3 full stops. For example, "This is a very long string" will become "This is a very..." DT_WORD_ELLIPSISWhen a word is too long to fit in the control Brass will draw as much as possible then replace the remaining characters in the word with 3 full stops. For example, "Supercalafragalisticexpialadocious" will become "Supercalafrag..." DT_RTLREADINGReverses the text into right-to-left order. DT_HIDEPREFIXRefer to DT_NOPREFIX. This style removes the ampersand character without underlining the next character. DT_PREFIXONLYDraws only an underline at the position of the character following the ampersand (&) prefix character. Does not draw any other characters in the string.
Return Value
None
Example Code
// Create a 150*40 control at 10, 10 and store its ID
int FirstTextID = createstatictext(1, 10, 10, 150, 40);
// Set the text to have a horizontal, grey shaded background with border
setstatictextstyle(FirstTextID, CTRL_HGRAD, True, RGB(100, 100, 100), RGB(200, 200, 200));
// Set a caption
setcaption(FirstTextID, "This is some text");
// Center the text horizontally and vertically, and force Brass to
// format it onto a single line
setstatictextformatting(FirstTextID, DT_CENTER | DT_VCENTER | DT_SINGLELINE);