Jump to content

Multiple Tab Controls


Recommended Posts

Concept: AutoIt supports multiple GUI windows, so create borderless mdi child windows to contain the additional tab controls.

Limitations: Gui Resize stuff is not automatically supported... Nested tab controls aren't supported--but it might be possible with more coding....

_createAnotherTab($left, $top, $width, $height)

_createAnotherTabItem($tabHandle, $text)

Screenshot attached :)

EDIT: Fixed positioning bug...

; CyberSlug - 23 Nov 2003
; Workaround to allow multiple tab controls on a GUI

; Create ANOTHER tab control at the specified coordinates, and return a handle...
Func _createAnotherTab($left, $top, $width, $height)
   Local $parentGui = WinGetHandle("")
   Local $style = 0x56000000;WS_CHILD + WS_VISIBLE + WS_CLIPSIBLINGS + WS_CLIPCHILDREN
  ;I'm not sure why the -10 is needed, but it seems to calculate the right x,y coords
   $tabCtrlWin = GuiCreate("", $width, $height, $left,$top, $style, -1, $parentGui)
   GuiCtrlCreateTab(0, 0, $width, $height)
   GuiSetState()
   GuiSwitch($parentGui)
   Return $tabCtrlWin
EndFunc

; Add a tabitem to the specified tab control
Func _createAnotherTabItem($tabHandle, $text)
   Local $parentGui = WinGetHandle("")
  ; it would be better to explicitly use the handle of the parent GUI, but this the above
  ;  function seems to work
   GuiSwitch($tabHandle)
   Local $item = GuiCtrlCreateTabItem($text)
   If $text = "" Then GuiSwitch($parentGui);remember null text denotes "closing" tabitem
   Return $item
EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;; EXAMPLE CODE;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Opt("TrayIconDebug", 1);DEBUG ON
$GUI = GuiCreate("Example Tab Controls", 400, 300)

$info = GuiCtrlCreateButton("Info", 280, 50, 100, 50)

Dim $button[8]

$tab0 = GuiCtrlCreateTab(10, 10, 100, 100)
GUICtrlCreateTabItem("zero")
   GuiCtrlCreateButton("this", 40, 40, 50, 50)
GUICtrlCreateTabItem("one")
   GuiCtrlCreateButton("is", 40, 40, 50, 50)
GUICtrlCreateTabItem("")

$tab1 = _createAnotherTab(150, 10, 100, 100)
_createAnotherTabItem($tab1, "A")
   GuiCtrlCreateButton("rather", 40, 40, 50, 50)
_createAnotherTabItem($tab1, "B")
   GuiCtrlCreateButton("cool", 40, 40, 50, 50)
_createAnotherTabItem($tab1, "")

$tab2 = _createAnotherTab(10, 150, 100, 100)

_createAnotherTabItem($tab2, "Two")
   GuiCtrlCreateButton("more", 40, 40, 50, 50)
_createAnotherTabItem($tab2, "Three")
   GuiCtrlCreateButton("buttons", 40, 40, 50, 50)
_createAnotherTabItem($tab2, "")

$handle2 = _createAnotherTab(150, 150, 100, 100)
_createAnotherTabItem($handle2, "  i")
   GuiCtrlCreateButton("hi", 40, 40, 50, 50)
_createAnotherTabItem($handle2, "  ii")
   GuiCtrlCreateButton("there", 40, 40, 50, 50)
_createAnotherTabItem($handle2, "")

$close = GUICtrlCreateButton("Close", 280, 180, 100, 50)

GuiSetState()

While 1
   $msg = GuiGetMsg(1)
   $msg = $msg[0]
   If $msg > 0 Then WinSetTitle($GUI, "", "Last Control Clicked:  " & $msg)
   If $msg = -3 or $msg = $close Then ExitLoop
WEnd

Exit
Edited by CyberSlug
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 post
Share on other sites

Which version of AutoIT did you use?

<{POST_SNAPBACK}>

I used the newest unstable version.

By the way, the _createAnotherTab returns a handle to the window instead of the tab control itself. You might want to modify to return an array with both pieces of information.

(_createAnotherTabItem uses the window handle; but if you want to change any style properties of the tab control, you would need the control handle)

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 post
Share on other sites

Question for the devs:

Why does AutoIt only allow one tab control (per GUI) anyway?

<{POST_SNAPBACK}>

When I design the Gui tab control i did't when to scan in a lot of place to see the context so it was easier to have one. I will rehink and report more clearly if it is possible :)
Link to post
Share on other sites

I reread what I did and it is almost impossible to have several tab in the same window.

I never saw such gui in any application that I analyse, so I will not try to rewrite the entire tab handling in the gui stuff.

Sorry for not helping on this evolution. :idiot:

Link to post
Share on other sites

I reread what I did and it is almost impossible to have several tab in the same window.

....

Sorry for not helping on this evolution. :idiot:

<{POST_SNAPBACK}>

That's oka :"> . I'll add my tab workaround to AutoBuilder then.
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 post
Share on other sites

@CyberSlug:

How do you make the tabs stick on the parent window when the window moves?

Is it the styles you applied to the child windows?

<{POST_SNAPBACK}>

Yes. It was trial/error/guesswork. I using a spy program to capture the window styles from some MDI Applications; and I think the style I'm using is from Microsoft Excel.
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 post
Share on other sites

Yes.  It was trial/error/guesswork.  I using a spy program to capture the window styles from some MDI Applications; and I think the style I'm using is from Microsoft Excel.

<{POST_SNAPBACK}>

Thanks,

If you find out where in Excel I am curious too know because I never see a tab on tab GUI. :idiot:

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...