Jump to content

Setting TAB stops for GUICtrlCreateLabel ?


Mungo
 Share

Recommended Posts

I wonder if there is a way to set tab stops for a label control similarly as used by the Gary Frost's UDF _GUICtrlEdit_SetTabs($hWnd, $aTabStops) for edit controls ?

This would allow me to e.g. vertically aligned text along self-defined tab stops using @TAB.

I get similar effects using the edit control and making it look like a label (see example) ... or any other ideas?

Cheers :)

Mungo

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
Opt('MustDeclareVars', 1)
Example()

Func Example()
    Local $f_size = 10
    Local $tab_stops_a[4] = [5, 20, 200]                    ; Define stab stops

    Local $h_win = GUICreate ( "TEST GUI ... Set TAB stops", 500, 350)
    GUISetBkColor(0xffffff, $h_win)
    GUISetFont(10, 400, 0, "Arial", $h_win, 2)
    GUICtrlCreateLabel("Test: Set TAB stops ...", 10, 10)

    GUICtrlCreateLabel("Using LABEL ctrl with default tab stops ...", 10, 40, 380, 20)
    GUICtrlCreateLabel(@TAB &"-" &@TAB & "Col 1 - Some longer column text"  &@TAB & "[Col 2 - Units]", 10, 60, 450, 20)
    GUICtrlCreateLabel(@TAB &"-" &@TAB & "Col 1 - Short text"               &@TAB & "[Col 2 - Units]", 10, 80, 450, 20)

    GUICtrlCreateLabel("Using EDIT ctrl and setting tab stops where I want them to be ...", 10, 120, 380, 20)

    GUICtrlCreateEdit(@TAB &"-" &@TAB & "Col 1 - Some longer column text"   &@TAB & "[Col 2 - Units]", 10, 140, 450, 20, BitOR($ES_AUTOHSCROLL, $ES_READONLY), 0)
    GUICtrlSetBkColor(-1, 0xffffff)
    _GUICtrlEdit_SetTabStops(-1, $tab_stops_a)

    GUICtrlCreateEdit(@TAB &"-" &@TAB & "Col 1 - Short text"                &@TAB & "[Col 2 - Units]", 10, 160, 450, 20, BitOR($ES_AUTOHSCROLL, $ES_READONLY), 0)
    GUICtrlSetBkColor(-1, 0xffffff)
    _GUICtrlEdit_SetTabStops(-1, $tab_stops_a)

    Local $button = GUICtrlCreateButton("Close", 210, 310, 80, 20)
    GUISetState(@SW_SHOW)

    While 1
    Local $msg_pop = GUIGetMsg()
        Select
            Case $msg_pop = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg_pop = $button
                ExitLoop
        EndSelect
     WEnd
    GUIDelete()
EndFunc
Edited by Mungo
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...