Jump to content

How to make all controls within a group move, as the group moves?


 Share

Recommended Posts

Alright, I'm working on a nice sliding feature, as an alternative to tabs. But when I move the group, none of the controls move.

Any idea how to fix this?

(The button within group1 needs to move with group1)

Also, I'm trying to make it dynamic.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
;;Globals
Global $Slide_Amount[4]; Add one more than the amount of slides you have.
Global $Slide_Cur = 1; Current Slide (Default 1)
Global Const $Slide_Width = 377
Global Const $Slide_Height = 217
Global Const $Slide_Pos_X = 0
Global Const $Slide_Pos_Y = 40
Global Const $Slide_Border = 8
Global Const $Slide_Border_Add = $Slide_Border * 3 + 5
;;
$Form1 = GUICreate("Form1", 394, 267, 193, 125)
$Button1 = GUICtrlCreateButton("Slide 1", 8, 8, 121, 25, 0)
$Button2 = GUICtrlCreateButton("Slide 2", 136, 8, 121, 25, 0)
$Button3 = GUICtrlCreateButton("Slide 3", 264, 8, 121, 25, 0)
$Slide_Amount[1] = GUICtrlCreateGroup("Group1", $Slide_Pos_X + $Slide_Border, $Slide_Pos_Y, $Slide_Width, $Slide_Height)
GUICtrlCreateButton("Button1", 72, 96, 89, 41, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Slide_Amount[2] = GUICtrlCreateGroup("Group2", $Slide_Pos_X + $Slide_Border + $Slide_Border_Add + $Slide_Width, $Slide_Pos_Y, $Slide_Width, $Slide_Height)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Slide_Amount[3] = GUICtrlCreateGroup("Group3", $Slide_Pos_X + $Slide_Border + $Slide_Border_Add + $Slide_Width, $Slide_Pos_Y, $Slide_Width, $Slide_Height)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Slide(1)
        Case $Button2
            Slide("2"); Stings or numbers work.
        Case $Button3
            Slide(3)
    EndSwitch
WEnd

Func Slide($Slide_Number)
    Local $Slide_Loop = 0
    If $Slide_Cur = $Slide_Number Then
        Return 0
    Else
        Do
            $Slide_Loop -= 1
            GUICtrlSetPos($Slide_Amount[$Slide_Number], $Slide_Width + $Slide_Loop - $Slide_Border, $Slide_Pos_Y)
            GUICtrlSetPos($Slide_Amount[$Slide_Cur], $Slide_Pos_X - $Slide_Loop + $Slide_Border + $Slide_Border_Add, $Slide_Pos_Y)
            WinSetTitle($Form1, "", $Slide_Loop & " ==> Until " & $Slide_Width & " || " & $Slide_Cur)
        Until $Slide_Loop = ($Slide_Pos_X + $Slide_Border + $Slide_Width * 1) - (($Slide_Pos_X + $Slide_Border + $Slide_Width * 1) * 2) + 16 + $Slide_Border
        $Slide_Cur = $Slide_Number
        WinSetTitle($Form1, "", $Slide_Loop & " ==> Until " & $Slide_Width & " || " & $Slide_Cur)
    EndIf
EndFunc  ;==>Slide
Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Link to comment
Share on other sites

Not perfect, but real close ( you can adjust)

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
;;Globals
Global $Button[4]
Global $Slide_Amount[4]; Add one more than the amount of slides you have.
Global $Slide_Cur = 1; Current Slide (Default 1)
Global Const $Slide_Width = 377
Global Const $Slide_Height = 217
Global Const $Slide_Pos_X = 0
Global Const $Slide_Pos_Y = 40
Global Const $Slide_Border = 8
Global Const $Slide_Border_Add = $Slide_Border * 3 + 5
;;
$Form1 = GUICreate("Form1", 394, 267, 193, 125)
$Button1 = GUICtrlCreateButton("Slide 1", 8, 8, 121, 25, 0)
$Button2 = GUICtrlCreateButton("Slide 2", 136, 8, 121, 25, 0)
$Button3 = GUICtrlCreateButton("Slide 3", 264, 8, 121, 25, 0)
$Slide_Amount[1] = GUICtrlCreateGroup("Group1", $Slide_Pos_X + $Slide_Border, $Slide_Pos_Y, $Slide_Width, $Slide_Height)
$Button[1] = GUICtrlCreateButton("Button1", 72, 96, 89, 41, 0)

$Button[2] = GUICtrlCreateButton("Button2", 72 + $Slide_Width, 96, 89, 41, 0)

$Button[3] = GUICtrlCreateButton("Button3", 72  + $Slide_Width, 96, 89, 41, 0)


GUICtrlCreateGroup("", -99, -99, 1, 1)
$Slide_Amount[2] = GUICtrlCreateGroup("Group2", $Slide_Pos_X + $Slide_Border + $Slide_Border_Add + $Slide_Width, $Slide_Pos_Y, $Slide_Width, $Slide_Height)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Slide_Amount[3] = GUICtrlCreateGroup("Group3", $Slide_Pos_X + $Slide_Border + $Slide_Border_Add + $Slide_Width, $Slide_Pos_Y, $Slide_Width, $Slide_Height)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Slide(1)
        Case $Button2
            Slide("2"); Stings or numbers work.
        Case $Button3
            Slide(3)
    EndSwitch
WEnd

Func Slide($Slide_Number)
    Local $Slide_Loop = 0
    If $Slide_Cur = $Slide_Number Then
        Return 0
    Else
        Do
            $Slide_Loop -= 1
            GUICtrlSetPos($Slide_Amount[$Slide_Number], $Slide_Width + $Slide_Loop - $Slide_Border, $Slide_Pos_Y)
            GUICtrlSetPos($Slide_Amount[$Slide_Cur], $Slide_Pos_X - $Slide_Loop + $Slide_Border + $Slide_Border_Add, $Slide_Pos_Y)
            GUICtrlSetPos( $Button[$Slide_Number], 72 + $Slide_Width + $Slide_Loop, 96)
            GUICtrlSetPos( $Button[$Slide_Cur], $Slide_Pos_X - $Slide_Loop + 72, 96)
            WinSetTitle($Form1, "", $Slide_Loop & " ==> Until " & $Slide_Width & " || " & $Slide_Cur)
        Until $Slide_Loop = ($Slide_Pos_X + $Slide_Border + $Slide_Width * 1) - (($Slide_Pos_X + $Slide_Border + $Slide_Width * 1) * 2) + 16 + $Slide_Border
        $Slide_Cur = $Slide_Number
        WinSetTitle($Form1, "", $Slide_Loop & " ==> Until " & $Slide_Width & " || " & $Slide_Cur)
    EndIf
EndFunc  ;==>Slide

8)

NEWHeader1.png

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