Jump to content

Sys Tab Control 321 (autoit-gui)


Recommended Posts

Not sure where to post this message, but I have been playing with the SysTabControl in autoit-gui.102.17 and I have to say :huh2::):D

It even supports dynamic control creation!!! There is one quirk, but it can be very low priority on the to-do list because workarounds exist

Quirk If you dynamically create a new Tab containing new controls, then:

1) The old controls from the previous Tab do not disappear until you toggle between the Tabs a few times

2) The new controls on the new Tab do not appear until you create another Tab.

Sample script with workarounds:

Opt("GUINotifyMode", 1)

$count = 1
$TCM_DELETEITEM = 4872

GuiCreate("TitleFoo", 500, 500)
WinActivate("TitleFoo")
$Add = GUISetControl("button", "New tab", 300, 300)
$tab = GUISetControl("tab", "", 0, 0, 300, 300)
GUISetControl("tabitem", "1", 0, 0);, 300, 300)

GUISetControl("edit", "Edit on tab #" & $count , 40, 40, 150, 150)

GuiShow()
While 1
    sleep(100)
    $msg = GuiMsg(0)
    If $count >= 5 Then GuiWrite($Add, 128) ;disable the button

    Select
    Case -3 = $msg
        Exit

    Case $Add = $msg
        $count = $count + 1

       ; Make sure rightmost tab is active so that new tab is inserted
       ; at the far right.
        For $i = 1 to $count
            ControlCommand("","","SysTabControl321", "TabRight","")
        Next

       ; Create new tab with button
        GUISetControl("tabitem", $count, 0, 0)
        GUISetControl("edit", "Edit on tab #" & $count , 40, 40, 150, 150)

       ; Refreshs the tabs so that 'Button on tab #1' does not hang around
        ControlCommand("","","SysTabControl321", "TabRight","")
        ControlCommand("","","SysTabControl321", "TabLeft","")
        ControlCommand("","","SysTabControl321", "TabRight","")
        ControlCommand("","","SysTabControl321", "TabLeft","")

       ; Activate new tab
        ControlCommand("","","SysTabControl321", "TabRight","")

       ; In order for 'Editon tab #x' to appear, I must create another tab
       ; (and then I delete it)
        GUISetControl("tabitem", "  ", 0, 0)
        ControlCommand("","","SysTabControl321", "TabRight","")
        GuiSendMsg($tab, $TCM_DELETEITEM, $count, 0)

       ;Re-activate new tab
        For $i = 1 to $count
            ControlCommand("","","SysTabControl321", "TabRight","")
        Next
    EndSelect

WEnd
Exit

Note: ControlCommands will soon be replaced with native GUI functions.

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

WHy don't you use the basic in 102.17B

The tab numbering start at 0 and the closing of the tab definition is with "".

:D

Opt("GUINotifyMode", 1)

$count = 0
#include "GUI_Message.au3"

GuiCreate("TitleFoo", 500, 500)
WinActivate("TitleFoo")
$Add = GUISetControl("button", "New tab", 300, 300)
$tab = GUISetControl("tab", "", 0, 0, 300, 300)
GUISetControl("tabitem", $count, 0, 0);, 300, 300)

GUISetControl("edit", "Edit on tab #" & $count , 40, 40, 150, 150)

GuiShow()
While 1
   sleep(100)
   $msg = GuiMsg(0)
   If $count >= 5 Then GuiWrite($Add, 128);disable the button

   Select
   Case -3 = $msg
       Exit

   Case $Add = $msg
       GuiSendMsg($tab, $TCM_SETCURSEL, $count, 0)
      $count = $count + 1

     ; Create new tab with button
       GUISetControl("tabitem", $count, 0, 0)
       GUISetControl("edit", "Edit on tab #" & $count , 40, 50, 150, 150)
       
    GUISetControl("tabitem", "", 0, 0); close tab definition
    GuiSendMsg($tab, $TCM_SETCURFOCUS, $count, 0)
   EndSelect

WEnd
Exit

with the include being

;Edit/input control Messages
Global $EM_GETSEL    = 0x00B0
Global $EM_SETSEL    = 0x00B1
Global $EM_GETRECT   = 0x00B2
Global $EM_SETRECT   = 0x00B3
Global $EM_SETRECTNP  = 0x00B4
Global $EM_SCROLL    = 0x00B5
Global $EM_LINESCROLL  = 0x00B6
Global $EM_SCROLLCARET  = 0x00B7
Global $EM_GETMODIFY  = 0x00B8
Global $EM_SETMODIFY  = 0x00B9
Global $EM_GETLINECOUNT  = 0x00BA
Global $EM_LINEINDEX  = 0x00BB
Global $EM_SETHANDLE  = 0x00BC
Global $EM_GETHANDLE  = 0x00BD
Global $EM_GETTHUMB      = 0x00BE
Global $EM_LINELENGTH  = 0x00C1
Global $EM_REPLACESEL  = 0x00C2
Global $EM_GETLINE   = 0x00C4
Global $EM_LIMITTEXT  = 0x00C5
Global $EM_CANUNDO   = 0x00C6
Global $EM_UNDO    = 0x00C7
Global $EM_FMTLINES      = 0x00C8
Global $EM_LINEFROMCHAR  = 0x00C9
Global $EM_SETTABSTOPS  = 0x00CB
Global $EM_SETPASSWORDCHAR  = 0x00CC
Global $EM_EMPTYUNDOBUFFER  = 0x00CD
Global $EM_GETFIRSTVISIBLELINE= 0x00CE
Global $EM_SETREADONLY  = 0x00CF
Global $EM_SETWORDBREAKPROC = 0x00D0
Global $EM_GETWORDBREAKPROC = 0x00D1
Global $EM_GETPASSWORDCHAR  = 0x00D2
Global $EM_SETMARGINS  = 0x00D3
Global $EM_GETMARGINS  = 0x00D4
Global $EM_GETLIMITTEXT  = 0x00D5
Global $EM_POSFROMCHAR  = 0x00D6
Global $EM_CHARFROMPOS  = 0x00D7
Global $EM_SETIMESTATUS  = 0x00D8
Global $EM_GETIMESTATUS  = 0x00D9


; Tab control messages
Global $TCM_DELETEALLITEMS  = 0x1309
Global $TCM_DELETEITEM  = 0x1308
Global $TCM_DESELECTALL  = 0x1332
Global $TCM_GETCURFOCUS  = 0x132F
Global $TCM_GETCURSEL  = 0x130B
Global $TCM_GETEXTENDEDSTYLE= 0x1335
Global $TCM_GETITEMCOUNT    = 0x1304
Global $TCM_GETITEMRECT  = 0x130A
Global $TCM_GETROWCOUNT  = 0x132C
Global $TCM_HIGHLIGHTITEM   = 0x1333
Global $TCM_SETCURFOCUS  = 0x1330
Global $TCM_SETCURSEL  = 0x130C
Global $TCM_SETEXTENDEDSTYLE= 0x1334
Global $TCM_SETITEMSIZE  = 0x1329
Global $TCM_SETMINTABWIDTH  = 0x1331
Global $TCM_SETPADDING  = 0x132B

;Up-down Control messages
Global $UDM_GETBASE      = 0x400+110
Global $UDM_GETPOS   = 0x400+104
Global $UDM_GETRANGE  = 0x400+102
Global $UDM_SETBASE      = 0x400+109
Global $UDM_SETPOS   = 0x400+103
Global $UDM_SETRANGE  = 0x400+101

;Date control messages
Global $DTM_GETMCCOLOR  = 0x1007
Global $DTM_SETFORMAT  = 0x1005
Global $DTM_SETMCCOLOR  = 0x1006
Link to comment
Share on other sites

I promise to use #include "GUI_Message.au3" more :D

jpm, because you do not force the new tab to be inserted at the far right, there can be problems....

Try this with your example:

- Click "New Tab" button

- Click Tab #0

- Click "New Tab" button

- Click Tab #2

- Click Tab #1

Notice that Tab #1 is blank

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

I promise to use #include "GUI_Message.au3" more :D

jpm, because you do not force the new tab to be inserted at the far right, there can be problems....

Try this with your example:

- Click "New Tab" button

- Click Tab #0

- Click "New Tab" button

- Click Tab #2

- Click Tab #1

Notice that Tab #1 is blank

I think about and I will report what happening :huh2:
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...