Article ID: 110958
Article Last Modified on 10/29/2003
Sub Form_Load ()
Const WM_USER = &H400
Const LB_SETTABSTOPS = WM_USER + 19
Const maxlen = 10 ' Maximum expected string length in list box.
tabchar = Chr$(9) ' ASCII code for a tab
ReDim a$(maxlen) ' String array to right justify in list box.
form1.Show ' Must Show form in Load event before Print
' will become visible.
' GetDialogBaseUnits() API function lets you calculate the average
' width of characters in the system font.
bu& = GetDialogBaseUnits()
hiword = bu& \ (2 ^ 16) ' 16 pixels high in default system font.
loword = bu& And &HFFFF& ' 8 pixels wide in default system font.
Print "System font width and height, in pixels: " & loword, hiword
'Assign the array of defined tab stops.
Static tabs(1 To maxlen) As Integer
For j = 1 To maxlen ' Set tabs every 4 dialog units (one character):
tabs(j) = (loword * j) / 2
' On most Windows systems, you need only this: tabs(j) = j * 4
Next
'Send message to the List1 control through the Windows message queue:
retVal& = SendMessage(List1.hWnd, LB_SETTABSTOPS, maxlen, tabs(1))
For j = 1 To maxlen
a$(j) = String$(j, "a") ' Assign an arbitrary character string.
' Add the appropriate number of tabstops to right justify:
tabstring = String$(maxlen + 1 - Len(a$(j)), Chr$(9))
List1.AddItem tabstring & a$(j)
Next
End Sub
Declare Function GetDialogBaseUnits Lib "User" () As Long
' Enter the following Declare statement on one, single line:
Declare Function SendMessage Lib "user" (ByVal hWnd As Integer,
ByVal wMsg As Integer, ByVal wp As Integer, lp As Any) As Long
Additional query words: 3.00 alignment right-align align
Keywords: KB110958