TextSetHeight

Syntax

TextSetHeight(Text, LayoutHeight.d)

Description

Sets the maximum layout height constraint for the specified text object in device-independent pixels (DIPs).

Parameters

Text
The handle of the text object to modify.

LayoutHeight.d
The maximum height in DIPs for the text layout. If the text content exceeds this height, it might be clipped or trimmed depending on the TextSetTrimming() setting. Setting to #Null or 0 removes the height constraint.

Return Value

This function does not return a value.

Remarks

Setting a layout height affects vertical alignment (TextSetAlign()) and potentially text trimming. It defines the vertical bounds within which the text will be positioned or clipped.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

Global MyText

Procedure DrawHandler(Window, EventType, *EventData.PG_EventDraw)
    DrawClear(RGB(240, 240, 240), 1)
    DrawBoxStroke(10, 10, *EventData\width-20, *EventData\height-20, 0) ; Show layout bounds
    TextSetWidth(MyText, *EventData\width-20)
    TextSetHeight(MyText, *EventData\height-20)
    DrawTxt(MyText, 10, 10, 0)
EndProcedure

MyWindow = CreateWindow(0, 0, 200, 100, "Text Layout Height")

If MyWindow
    MyText = CreateText("This text might be clipped or trimmed if too long.", "Arial", 12)
    
    TextSetTrimming(MyText, #PG_Text_Trimming_Character) ; Add ellipses if trimmed

    AddEventHandler(MyWindow, #PG_Event_Draw, @DrawHandler())
    WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)
    Repeat: Event = WaitWindowEvent() : Until Event = #PB_Event_CloseWindow
    FreeText(MyText)
EndIf

StopProGUI()

See Also

CreateText, TextGetHeight, TextSetWidth, TextSetAlign, TextSetTrimming

Supported OS

Windows, Linux