REQ: Snippet showing how to set tab stops in a list control 
Author Message
 REQ: Snippet showing how to set tab stops in a list control

Howdy,

I'd like to get a snippet of code that shows how to set tab stops in a VB
list box control
I've done this before, but can't seem to remember (or find the old code)
how to do it.

Thanks



Fri, 16 Apr 1999 03:00:00 GMT  
 REQ: Snippet showing how to set tab stops in a list control

Quote:
> Howdy,

> I'd like to get a snippet of code that shows how to set tab stops in a VB
> list box control
> I've done this before, but can't seem to remember (or find the old code)
> how to do it.

> Thanks

Here are example solutions for VB3 and VB4

------VB3 SOLUTION----------

Global declaration:

Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal wMsg
As Integer, ByVal wParam As Integer, lParam As Any) As Long

Global function:
'***************************************************************************
******************
'  ROUTINE: SetListTabs  *slg*
'  PURPOSE: Set tab stops in a list box so that columns can be aligned (or
hidden)
'           Based on SetTabStops proceedure. Add ability to pass tabstop
values to procedure.
'    PARMS: hListBox - handle to the list box (does not work on combo
boxes)
'    NOTES: Modify the positions below for the columns needed or modify the
routine to accept
'           one or more locations
'           the numbers are in the somewhat vague but still useful unit of
characters
'           Added ability to set stops
' LASTEDIT:
Sub SetListTabs (ByVal hListBox As Integer, iPos1 As Integer, iPos2 As
Integer, iPos3 As Integer)

ReDim tabs(1 To 3) As Integer
    tabs(1) = iPos1   'position 200 is almost certainly hidden from the
user's view
    tabs(2) = iPos2   'likewise, even more so
    tabs(3) = iPos3

    giRes = SendMessage(hListBox, &H400 + 19, 3, tabs(1))
End Sub

----------VB4 SOLUTION---------------

'***************************************************************************
******************
'  ROUTINE: SetListTabs
'  PURPOSE: Set tab stops in a list box so that columns can be aligned (or
hidden)
'    PARMS: CTR - list box control (does not work on combo boxes)
'           iPos1 - position of first tab
'           iPos2 - position of second tab, is optional
'           iPos3 - position of third tab, is optional
'    NOTES: Modify the positions below for the columns needed or modify the
routine to accept
'           one or more locations
'           the numbers are in the somewhat vague but still useful unit of
characters
'   LASTEDIT: MAV 10/14/96 - Modified to accept control instead of handle
Sub SetListTabs(CTR As ListBox, iPos1 As Integer, Optional iPos2 As
Variant, Optional iPos3 As Variant)
Dim iTabs As Integer
Dim iCnt As Integer
Dim hListBox As Long
Const LB_SetListTabs = &H192
Dim Tabs() As Long

    hListBox = CTR.Hwnd

    iTabs = 1
    If IsMissing(iPos2) = False Then
        iTabs = 2
        If IsMissing(iPos3) = False Then iTabs = 3
    End If

    ReDim Tabs(1 To iTabs) As Long
    For iCnt = 1 To iTabs
        Tabs(iTabs) = iPos1   'position 200 is almost certainly hidden from
the user's view
    Next

    giRes = SendMessage(hListBox, LB_SetListTabs, iTabs, Tabs(1))

End Sub



Mon, 19 Apr 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VB 5.0 and setting list box tab stops

2. setting columns or tab stops in a list box

3. Setting tab stops in a list box...

4. Setting tab stops in list box

5. Setting the tab stops in outline controls.

6. How to set the current tab in Tab control of MS COMMON CONTROL

7. Set Tab Stop on Printer?

8. Setting tab stops in VB5 listbox

9. Set Tab Stop on Printer?

10. Setting tab stops on Windows system printer

11. List Box Tab Stops

12. Setting printer tab stops

 

 
Powered by phpBB® Forum Software