Sign in to follow this  
Followers 0
Gnat

Sliding toolbar in a bigger gui

8 posts in this topic

Has anyone done a larger gui that has a part of it that is a sliding toolbar? I am working on a gui that has several parts and wanted to have a "docked" sliding toolbar that will allow the user to call particular functions or apps from the sliding toolbar.

Share this post


Link to post
Share on other sites



That is the post that gave me the idea for the sliding toolbar, but it is its own gui. What I want to do is add it to a bigger gui, and I am not sure how to extract the right code from the toolbar examples on that post. I am fairly new to the gui making process in AutoIT, and need some help on that...

Thanx in advance.

Share this post


Link to post
Share on other sites

you can just create the gui by specifying :

guicreate("",100,@deskopheight)

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


Link to post
Share on other sites

I have the base gui created, but I want to add in the sliding toolbar. Any other hints?

Thanx

Share this post


Link to post
Share on other sites

maybe...

; MsgBox(0x0,"", @AutoItVersion)
#include <GUIConstants.au3>
Global $hide_state = 0, $btn_state = 0, $side = "left"
Global $Button_[8], $Label_[8]

; your GUI
$main = GUICreate("MY BIG GUI")
$Show_btn = GUICtrlCreateButton("Show Slider", 100, 50, 80, 20)
$Hide_btn = GUICtrlCreateButton("Hide Slider", 100, 150, 80, 20)
GUISetState()

; slider GUI
$hwnd = GUICreate("Sliding Toolbar", 613, 85, -598, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW), $main)
$Show = GUICtrlCreateButton(">", 595, 8, 17, 70, BitOR($BS_CENTER, $BS_FLAT))
$author = GUICtrlCreateLabel(" By...   Simucal  &&  Valuater", 120, 25, 400, 40)
GUICtrlSetFont(-1, 20, 700)
GUISetState(@SW_HIDE, $hwnd)

$hwnd2 = GUICreate("Sliding Toolbar", 613, 85, 0, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW), $main)
$Button_[1] = GUICtrlCreateButton("Btn 1", 30, 35, 73, 41)
$Label_[1] = GUICtrlCreateLabel("Button 1", 49, 6, 60, 17)
$Button_[2] = GUICtrlCreateButton("Btn 2", 110, 35, 73, 41)
$Label_[2] = GUICtrlCreateLabel("Button 2", 128, 6, 60, 17)
$Button_[3] = GUICtrlCreateButton("Btn 3", 190, 35, 73, 41)
$Label_[3] = GUICtrlCreateLabel("Button 3", 207, 6, 43, 17)
$Button_[4] = GUICtrlCreateButton("Btn 4", 270, 35, 73, 41)
$Label_[4] = GUICtrlCreateLabel("Button 4", 287, 6, 75, 17)
$Button_[5] = GUICtrlCreateButton("Btn 5", 350, 35, 73, 41)
$Label_[5] = GUICtrlCreateLabel("Button 5", 368, 6, 75, 17)
$Button_[6] = GUICtrlCreateButton("Btn 6", 430, 35, 73, 41)
$Label_[6] = GUICtrlCreateLabel("Button 6", 447, 6, 40, 17)
$Button_[7] = GUICtrlCreateButton("Btn 7", 510, 35, 73, 41)
$Label_[7] = GUICtrlCreateLabel("Button 7", 526, 6, 60, 17)
$Hide = GUICtrlCreateButton("<", 595, 8, 17, 70);, BitOR($BS_CENTER, $BS_FLAT, $BS_MULTILINE))
For $i = 1 To 7
    GUICtrlSetCursor($Button_[$i], 0)
Next
;DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd2, "int", 500, "long", 0x00040001);slide in from left
GUISetState(@SW_HIDE)




While 1
    $msg1 = GUIGetMsg()
    
    If $msg1 = $Show_btn Then
        Slide_in()
        GUISwitch($hwnd2)
        GUISetState(@SW_SHOW, $hwnd2)
    EndIf
    
    If $msg1 = $Hide_btn Then
        GUISetState(@SW_HIDE, $hwnd)
        GUISetState(@SW_HIDE, $hwnd2)
        GUISwitch($main)
    EndIf
    
    ; Slider controls
    
    If $msg1 = $GUI_EVENT_CLOSE Then Exit
    If $msg1 = $Hide Then Slide_out()
    If $msg1 = $Show Then Slide_in()
    $a_pos = WinGetPos($hwnd2)
    $a_pos2 = WinGetPos($hwnd)
    If $side = "left" Then
        If $a_pos[0]+306 < (@DesktopWidth / 2) Then
            If $a_pos[0] <> 0 And $hide_state = 0 And $a_pos[0] Then
                WinMove($hwnd2, "", 0, $a_pos[1])
                WinMove($hwnd, "", -598, $a_pos[1])
            EndIf
            If $a_pos2[0] <> - 598 And $hide_state = 1 Then
                WinMove($hwnd, "", -598, $a_pos2[1])
                WinMove($hwnd2, "", 0, $a_pos2[1])
            EndIf
        Else
            SideSwitch()
        EndIf
    EndIf
    If $side = "right" Then
        If $a_pos[0]+306 > (@DesktopWidth / 2) Then
            If $a_pos[0] <> @DesktopWidth-613 And $hide_state = 0 Then
                WinMove($hwnd2, "", (@DesktopWidth-613), $a_pos[1])
                WinMove($hwnd, "", (@DesktopWidth-18), $a_pos[1]) ; should be -15
            EndIf
            If $a_pos2[0] <> (@DesktopWidth-18) And $hide_state = 1 Then ; should be -15
                WinMove($hwnd, "", (@DesktopWidth-18), $a_pos2[1]) ; should be -15
                WinMove($hwnd2, "", (@DesktopWidth-613), $a_pos2[1])
            EndIf
        Else
        SideSwitch()
        EndIf
    EndIf
    If $hide_state = 0 Then
        $a_mpos = GUIGetCursorInfo($hwnd2)
        If IsArray($a_mpos) = 1 Then
            For $b = 1 To 7
                If $a_mpos[4] = $Button_[$b] Then
                    If $b = 1 Then $left = 25
                    If $b > 1 Then $left = (($b - 1) * 80) + 25
                    GUICtrlSetPos($Button_[$b], $left, 30, 83, 46)
                    GUICtrlSetColor($Label_[$b], 0xff0000)
                    GUICtrlSetFont($Button_[$b], 8, 400, 4, "MS Sans Serif")
                    While $a_mpos[4] = $Button_[$b]
                        $a_mpos = GUIGetCursorInfo($hwnd2)
                        If IsArray($a_mpos) <> 1 Then ExitLoop
                        If $a_mpos[2] = 1 Then
                            Call("Function" & $B)
                            ExitLoop
                        EndIf
                        ;$a_mpos = GUIGetCursorInfo($hwnd2)
                        ;If IsArray($a_mpos) <> 1 Then ExitLoop
                    WEnd
                    $left = $left + 5
                    GUICtrlSetPos($Button_[$b], $left, 35, 73, 41)
                    GUICtrlSetColor($Label_[$b], 0x000000)
                    GUICtrlSetFont($Button_[$b], 8, 400, -1, "MS Sans Serif")
                EndIf
            Next
        EndIf
    EndIf
WEnd

Func Slide_in()
    $hide_state = 0
    ;Btn_reset()
    GUISetState(@SW_HIDE, $hwnd)
    If $side = "left" Then DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd2, "int", 500, "long", 0x00040001);slide in from left
    If $side = "right" Then DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd2, "int", 500, "long", 0x00040002);slide in from right
    WinActivate($hwnd2)
    WinWaitActive($hwnd2)
EndFunc   ;==>Slide_in

Func Slide_out()
    $hide_state = 1
    ;Btn_reset()
    If $side = "left" Then DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd2, "int", 500, "long", 0x00050002);slide out to left
    If $side = "right" Then DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd2, "int", 500, "long", 0x00050001);slide out to right
    GUISetState(@SW_SHOW, $hwnd)
    WinActivate($hwnd)
    WinWaitActive($hwnd)
EndFunc   ;==>Slide_out

Func SideSwitch()
    If $side = "left" Then
        $side = "right"
        GuiCtrlSetPos($Hide,1,8)
        GuiCtrlSetData($Hide, ">")
        GuiCtrlSetPos($Show,1,8)
        GuiCtrlSetData($Show, "<")
    Else
        $side = "left"
        GuiCtrlSetPos($Hide,595, 8)
        GuiCtrlSetData($Hide, "<")
        GuiCtrlSetPos($Show,595, 8)
        GuiCtrlSetData($Show, ">")
    EndIf
EndFunc
        


Func Function1()
    Slide_out()
    ; do stuff
EndFunc   ;==>Function1
Func Function2()
    Slide_out()
    ; do stuff
EndFunc   ;==>Function2
Func Function3()
    Slide_out()
    ; do stuff
EndFunc   ;==>Function3
Func Function4()
    Slide_out()
    ; do stuff
EndFunc   ;==>Function4
Func Function5()
    Slide_out()
    ; do stuff
EndFunc   ;==>Function5
Func Function6()
    Slide_out()
    ; do stuff
EndFunc   ;==>Function6
Func Function7()
    Slide_out()
    ; do stuff
EndFunc   ;==>Function7

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

That is definitely closer to what I was talking about, but I was hoping that I would actually be able to anchor it to the left or right side of the gui, instead of anchoring to the left or right side of the desktop.

Thanx

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

OKKK

i've understood

search on the forum for my toolbar

i've used a sliding gui that slow down from the main gui

you have to get the current gui position, etc...

try it

; MsgBox(0x0,"", @AutoItVersion)
#include <GUIConstants.au3>
Global $hide_state = 0, $btn_state = 0, $side = "left"
Global $Button_[8], $Label_[8]

; your GUI
$main = GUICreate("MY BIG GUI")
$Show_btn = GUICtrlCreateButton("Show Slider", 100, 50, 80, 20)
$Hide_btn = GUICtrlCreateButton("Hide Slider", 100, 150, 80, 20)
GUISetState()

; slider GUI
$hwnd = GUICreate("Sliding Toolbar", 100, 500, -598, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW), $main)
$Show = GUICtrlCreateButton(">", 595, 8, 17, 70, BitOR($BS_CENTER, $BS_FLAT))
$author = GUICtrlCreateLabel(" By...   Simucal  &&  Valuater", 120, 25, 400, 40)
GUICtrlSetFont(-1, 20, 700)
GUISetState(@SW_HIDE, $hwnd)
$Hide = GUICtrlCreateButton("<", 595, 8, 17, 70);, BitOR($BS_CENTER, $BS_FLAT, $BS_MULTILINE))
;For $i = 1 To 7
;    GUICtrlSetCursor($Button_[$i], 0)
;Next
;DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd2, "int", 500, "long", 0x00040001);slide in from left
;GUISetState(@SW_HIDE)

$side="right" ;choose one

While 1
    $msg1 = GUIGetMsg()
    ; Slider controls
    If $msg1 = $GUI_EVENT_CLOSE Then Exit
    If $msg1 =  $Hide_btn Then Slide_out()
    If $msg1 = $Show_btn Then Slide_in()

WEnd

Func Slide_in()
    ConsoleWrite("sliding in" & @crlf)
    $hide_state = 0
    $pos=WinGetPos($main) ;get the main gui current position + size
    WinMove($hwnd,"",$pos[0]+$pos[2],$pos[1])
    ConsoleWrite("Win move " &$pos[0]+$pos[2] & " | " & $pos[1] & @crlf)
    ;Btn_reset()
    GUISetState(@SW_HIDE, $hwnd)
    If $side = "left" Then DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00040001);slide in from left
    If $side = "right" Then DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00040002);slide in from right
    WinActivate($hwnd)
    WinWaitActive($hwnd)
EndFunc   ;==>Slide_in

Func Slide_out()
    $hide_state = 1
    ;Btn_reset()
    If $side = "left" Then DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00050002);slide out to left
    If $side = "right" Then DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00050001);slide out to right
    WinActivate($main)
    WinWaitActive($main)
EndFunc   ;==>Slide_out

Func SideSwitch()
    If $side = "left" Then
        $side = "right"
        GuiCtrlSetPos($Hide,1,8)
        GuiCtrlSetData($Hide, ">")
        GuiCtrlSetPos($Show,1,8)
        GuiCtrlSetData($Show, "<")
    Else
        $side = "left"
        GuiCtrlSetPos($Hide,595, 8)
        GuiCtrlSetData($Hide, "<")
        GuiCtrlSetPos($Show,595, 8)
        GuiCtrlSetData($Show, ">")
    EndIf
EndFunc
        


Func Function1()
    Slide_out()
    ; do stuff
EndFunc   ;==>Function1
Func Function2()
    Slide_out()
    ; do stuff
EndFunc   ;==>Function2
Func Function3()
    Slide_out()
    ; do stuff
EndFunc   ;==>Function3
Func Function4()
    Slide_out()
    ; do stuff
EndFunc   ;==>Function4
Func Function5()
    Slide_out()
    ; do stuff
EndFunc   ;==>Function5
Func Function6()
    Slide_out()
    ; do stuff
EndFunc   ;==>Function6
Func Function7()
    Slide_out()
    ; do stuff
EndFunc   ;==>Function7
Edited by arcker

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


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
Sign in to follow this  
Followers 0