PslTransString.GetContentSize
Returns the optimal size of a dialog item. This is the same size that is used from the command "Size to content".
Syntax
Expression.GetContentSize (Cx as LONG, Cy as LONG) as Boolean
Expression Object of type PslTransString
Cx Width, calculated from the content of the string
Cy Height, calculated from the content of the string
Example
Checks all translation string and corrects the "Text does not fit control size" errors automatically
Sub Main
Dim trn As PslTransList
Set trn = PSL.ActiveTransList
If trn Is Nothing Then Exit Sub
' Make sure that the CheckControlSize option is set
PSL.Option(pslOptionCheckCtrlSize) = True
' Check the strings
trn.Check
' Peek at the output window to get the errors that have been found
Dim checkwnd As PslOutputWnd
Set checkwnd = PSL.OutputWnd(pslOutputWndCheck)
Dim Line As Long
For Line = 1 To checkwnd.LineCount
If checkwnd.Type(Line) = pslOutputJump And _
checkwnd.JumpError(Line) = 301 Then
Dim t As PslTransString
Set t = trn.String(checkwnd.JumpNumber(Line), pslNumber)
Dim x As Long
Dim y As Long
Dim cx As Long
Dim cy As Long
t.GetRect(x, y, cx, cy)
If t.GetContentSize(cx, cy) Then
t.SetRect(x, y, cx, cy)
PSL.Output "Resized string " & Str(t.Number) & ": (" & CStr(cx) & "," & CStr(cy) & ")"
End If
End If
Next Line
End Sub