Jump to content

XP Style Control Possible in AutoIT ?


 Share

Recommended Posts

What specific portion of the menu are you wanting to emulate?

It is possible to create a menu with tabs that can open and close with the window resizing properly. Check out "WinMove" in the help files. With that command you can resize windows.

Code Outline:

1) Click Button Toggle

2) WinMove either larger or smaller as necessary

3) Show or hide the contents of the tab

Good luck.

Bob

You can't see a rainbow without first experiencing the rain.

Link to comment
Share on other sites

Sorry about the triple post, but I have found the problems with the above script (post deleted for ease of reading thread). Controls are resized as the window is resized, thus they need to be docked. However, the controls below the first one need to move before the window is sized (else the original coordinates are off). This is easy enough to keep track of when the number of elements is small but it is probably easier if the controls are in an array as in the example script.

#include-once
#include <GUIConstantsEx.au3>

Opt("MouseCoordMode", 2)
Opt("GUIOnEventMode", 1)
Dim $Tab2[4]

$Form1 = GUICreate("Menu", 248, 70, 340, 240)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$Label1 = GUICtrlCreateLabel("Test One", 8, 16, 48, 17)
GUICtrlSetResizing(-1,$GUI_DOCKTOP)
$B_Open1 = GUICtrlCreateButton("O", 192, 16, 41, 17, 0)
GUICtrlSetOnEvent(-1,"_Open")
GUICtrlSetResizing(-1,$GUI_DOCKTOP + $GUI_DOCKSIZE)
$Label_Open1 = GUICtrlCreateLabel("This is the information under the frist tab", 8, 35, 232, 50)
GUICtrlSetResizing(-1,$GUI_DOCKTOP + $GUI_DOCKSIZE)
GUICtrlSetState(-1,$GUI_HIDE)
;toggle close button for section 1 (hidden)
$B_Close1 = GUICtrlCreateButton("C", 192, 16, 41, 17, 0)
GUICtrlSetOnEvent(-1,"_Close")
GUICtrlSetResizing(-1,$GUI_DOCKTOP + $GUI_DOCKSIZE)
GUICtrlSetState(-1,$GUI_HIDE)
$Tab2[0] = GUICtrlCreateLabel("Test Two", 8, 35, 49, 17)
GUICtrlSetResizing(-1,$GUI_DOCKTOP + $GUI_DOCKSIZE)
;open button
$Tab2[1] = GUICtrlCreateButton("O", 192, 35, 41, 17, 0)
GUICtrlSetResizing(-1,$GUI_DOCKTOP + $GUI_DOCKSIZE)
GUICtrlSetOnEvent(-1,"_Open")
$Tab2[2] = GUICtrlCreateLabel("This is the information under the second tab", 8, 54, 232, 50)
GUICtrlSetResizing(-1,$GUI_DOCKTOP + $GUI_DOCKSIZE)
GUICtrlSetState(-1,$GUI_HIDE)
;toggle close button for section 2 (hidden)
$Tab2[3] = GUICtrlCreateButton("C", 192, 35, 41, 17, 0)
GUICtrlSetResizing(-1,$GUI_DOCKTOP + $GUI_DOCKSIZE)
GUICtrlSetOnEvent(-1,"_Close")
GUICtrlSetState(-1,$GUI_HIDE)
GUISetState(@SW_SHOW)

;idle
While 1
    Sleep(100)
WEnd

Func _Exit()
    GUIDelete($Form1)
    Exit
EndFunc;==>_Exit()

Func _Open()
    Local $temp = @GUI_CtrlID
    Local $arWinInfo = WinGetPos("Menu")
    Local $arCtrlInfo
    GUICtrlSetState($temp,$GUI_HIDE)
    Switch $temp
        Case $B_Open1
            GUICtrlSetState($B_Close1,$GUI_SHOW)
            GUICtrlSetState($Label_Open1,$GUI_SHOW)
            For $element In $Tab2
                $arCtrlInfo=ControlGetPos("Menu","",$element)
                GUICtrlSetPos($element,$arCtrlInfo[0],$arCtrlInfo[1]+52)
            Next
            WinMove("Menu","",$arWinInfo[0],$arWinInfo[1],$arWinInfo[2],$arWinInfo[3]+52)
        Case $Tab2[1]
            GUICtrlSetState($Tab2[3],$GUI_SHOW)
            GUICtrlSetState($Tab2[2],$GUI_SHOW)
            WinMove("Menu","",$arWinInfo[0],$arWinInfo[1],$arWinInfo[2],$arWinInfo[3]+52)
    EndSwitch
EndFunc;==>_Open

Func _Close()
    Local $temp = @GUI_CtrlID
    Local $arWinInfo = WinGetPos("Menu")
    Local $arCtrlInfo
    GUICtrlSetState($temp,$GUI_HIDE)
    Switch $temp
        Case $B_Close1
            GUICtrlSetState($B_Open1,$GUI_SHOW)
            For $element In $Tab2
                $arCtrlInfo=ControlGetPos("Menu","",$element)
                GUICtrlSetPos($element,$arCtrlInfo[0],$arCtrlInfo[1]-52)
            Next
            WinMove("Menu","",$arWinInfo[0],$arWinInfo[1],$arWinInfo[2],$arWinInfo[3]-52)
            GUICtrlSetState($Label_Open1,$GUI_HIDE)
        Case $Tab2[3]
            GUICtrlSetState($Tab2[2],$GUI_HIDE)
            GUICtrlSetState($Tab2[1],$GUI_SHOW)
            WinMove("Menu","",$arWinInfo[0],$arWinInfo[1],$arWinInfo[2],$arWinInfo[3]-52)
    EndSwitch
EndFunc;==>_Open

Just needs to be prettied up and generalized! Each section can have its own resize value. Currently both sections are 50 pixels high with a two pixel border, thus the window is resized by 52 pixels.

Good luck.

Bob

Edited by YellowLab

You can't see a rainbow without first experiencing the rain.

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...