home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / source / chap20 / mltilist.fn next >
Text File  |  1995-09-21  |  2KB  |  38 lines

  1. Declare Function GetFocus Lib "user" () As Integer
  2. Declare Function SendMessage Lib "user" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wp As Integer, lp As Any) As Long
  3. Declare Function PutFocus Lib "user" Alias "SetFocus" (ByVal hWnd%) As Integer
  4.  
  5. Const WM_USER = &H400
  6. Const LB_SETTABSTOPS = WM_USER + 19
  7.  
  8. Sub Form_Click()
  9.    Dim retVal&, R%                    'API return values
  10.    Dim hOldWnd%, lbhWnd%              'WinCtrl handles
  11.    Static tabs(3) As Integer
  12.  
  13.    tabs(1) = 10                       'Set up array of defined tab stops.
  14.    tabs(2) = 70
  15.    tabs(3) = 130
  16.  
  17.    hOldWnd% = GetFocus()              'Remember who had the focus.
  18.    Form1.Show                         'Showing the form avoids  "Illegal
  19.                                       ' Function Call" on 'List1.SetFocus'
  20.    list1.SetFocus                     'Set the focus to the list box.
  21.    lbhWnd% = GetFocus()               'Get the handle to the list box.
  22.  
  23.    'Send a message to the message queue.
  24.    retVal& = SendMessage(lbhWnd%, LB_SETTABSTOPS, 3, tabs(1))
  25.  
  26.    R% = PutFocus(hOldWnd%)            'Restore handle to whoever had it.
  27.  
  28.    'Place some elements into the list box, separated by TAB chars:
  29.    list1.AddItem "Last Name" + Chr$(9) + "First Name" + Chr$(9) + "Year"
  30.    list1.AddItem "Washington" + Chr$(9) + "George" + Chr$(9) + "1789"
  31.    list1.AddItem "Adams" + Chr$(9) + "John" + Chr$(9) + "1797"
  32.    list1.AddItem "Jefferson" + Chr$(9) + "Thomas" + Chr$(9) + "1801"
  33.    list1.AddItem "Madison" + Chr$(9) + "James" + Chr$(9) + "1809"
  34.    list1.AddItem "Monroe" + Chr$(9) + "James" + Chr$(9) + "1817"
  35.    list1.AddItem "Adams" + Chr$(9) + "John Q." + Chr$(9) + "1825"
  36. End Sub
  37.  
  38.