Page 1 sur 1

[R] Bonne question comment s'appelle cette fonction (GUI splitters)

Posté : mer. 10 oct. 2018 01:02
par Anthony
Bonjour à tous,

Alors voilà je ne sais pas comment traduire avec des mots simples ce que je cherche à faire :shock:
En fait j'ai pas mal cherché mais sans succès la fonction qui permet de déplacer deux objets dans une même fenêtre par une barre glissante, défilante, redimensionnable ?
Cette barre se situe à droite de la petit flèche rouge donc voilà je n'arrive pas à éclairer ma lanterne car je sèche.
En gros çà réduit à gauche et agrandit à droite et inversement :?

Merci ;)

Image

Re: [..] Bonne question comment s'appelle cette fonction

Posté : mer. 10 oct. 2018 01:40
par orax
Sur la page MDI de Wikipédia, j'ai trouvé le terme « GUI splitters » (ou « séparateurs »). Je crois que c'est comme cela que se nomme cette barre. J'espère t'avoir aidé un peu.

https://en.wikipedia.org/wiki/Multiple_ ... _interface

Re: [..] Bonne question comment s'appelle cette fonction  

Posté : mer. 10 oct. 2018 08:49
par mikell
Melba23 a fait une UDF complète sur le sujet, ici

Re: [..] Bonne question comment s'appelle cette fonction

Posté : mer. 10 oct. 2018 12:52
par walkson

Code : Tout sélectionner

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#include <StaticConstants.au3>
#include <GuiStatusbar.au3>

;===============================================================================
; FileName:         splitterdemo.au3
; Description:    Splitter Bar demo
;
; Requirement:
; Author(s):        eltorro (Steve Podhajecki <gehossafats@netmdc.com>) modified by Tresa
; Note(s):          This is just a proof of concept at the moment.
;                   This could be tweaked into a udf with a little more work
;                   The basic principle is to create a pic box or label and drag it
;                   then resize the controls.
;                   I bowwored some filler for the tree and list from the help files.
;https://www.autoitscript.com/forum/topic/141079-solved-bar-to-divide-a-gui/?tab=comments#comment-991894
;===============================================================================
;$WM_SIZE =0x0005
Global $Form1Height = 448
Global $Form1Width = 622
Global $splitWidth = 5
Global $leftVSplit = 144
Global $topHSplit = 320
Global $topMargin = 6
Global $leftMargin = 4
Global $rigthMargin = 4
Global $bottomMargin = 6
Global $statusBarHeight

$Form1 = GUICreate("Splitter Demo", $Form1Width, $Form1Height, 192, 125, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_CLIPCHILDREN))

$TreeView1 = GUICtrlCreateTreeView($leftMargin, $topMargin, $leftVSplit - $leftMargin, $topHSplit - $topMargin, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$generalitem = GUICtrlCreateTreeViewItem("General", $TreeView1)
GUICtrlSetColor(-1, 0x0000C0)
$displayitem = GUICtrlCreateTreeViewItem("Display", $TreeView1)
GUICtrlSetColor(-1, 0x0000C0)
$aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem)
$compitem = GUICtrlCreateTreeViewItem("Computer", $generalitem)
$useritem = GUICtrlCreateTreeViewItem("User", $generalitem)
$resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem)
$otheritem = GUICtrlCreateTreeViewItem("Other", $displayitem)
GUICtrlSetState($generalitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "General"-item and paint in bold
GUICtrlSetState($displayitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "Display"-item and paint in bold


$ListView1 = GUICtrlCreateListView("col1  |col2|col3  ", $leftVSplit + $splitWidth, $topMargin, $Form1Width - $rigthMargin - ($leftVSplit + $splitWidth), $topHSplit - $topMargin, -1, $WS_EX_CLIENTEDGE)
$item1 = GUICtrlCreateListViewItem("item2|col22|col23", $ListView1)
$item2 = GUICtrlCreateListViewItem("item1|col12|col13", $ListView1)
$item3 = GUICtrlCreateListViewItem("item3|col32|col33", $ListView1)
GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping
GUISetState()
GUICtrlSetData($item2, "ITEM1")
GUICtrlSetData($item3, "||COL33")

;horizontal divider.
$Pic2 = GUICtrlCreatePic("", $leftMargin, $topHSplit, $Form1Width - $leftMargin - $rigthMargin, $splitWidth, $SS_NOTIFY);!!! BitOR($SS_NOTIFY, $SS_ETCHEDFRAME), $WS_EX_CLIENTEDGE)
GUICtrlSetCursor($Pic2, 11)

;vertical divider
$Pic1 = GUICtrlCreateLabel("", $leftVSplit, $topMargin, $splitWidth, $topHSplit - $topMargin, $SS_NOTIFY)
GUICtrlSetCursor($Pic1, 13)

;statusBar
Local $a[3] = [150, 350, -1]
Local $b[3] = ["Ready.", "", ""], $DragCtrl = ""
$Status1 = _GuiCtrlStatusBar_Create($Form1, $a, $B)
Local $a_rect = _GUICtrlStatusBar_GetRect($Status1, 1)
$statusBarHeight = ($a_rect[3] - $a_rect[1])

$Edit1 = GUICtrlCreateEdit("", $leftMargin, $topHSplit + $splitWidth, $Form1Width - $leftMargin - $rigthMargin, $Form1Height - $bottomMargin - $statusBarHeight - $topHSplit - $splitWidth, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetData($Edit1, "Drag the bars between the controls and they will resize." & @CRLF & _
        "Resize the screen and see what happens." & @CRLF & _
        "The Status bar show True the left mouse button is down and over a splitter.")

Opt("MouseCoordMode", 2)

GUISetState(@SW_SHOW)
Dim $precedingMsg, $stopTime
ResizeControls()
GUIRegisterMsg($WM_SIZE, "RESIZE_CONTROLS")
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_PRIMARYDOWN
            _GuiCtrlStatusBar_SetText($Status1, "Primary Down", 0)
        Case $msg = $Pic1
            If $DragCtrl = "" Then _GuiCtrlStatusBar_SetText($Status1, "Pic1 Primary Down", 0)
            $DragCtrl = $Pic1

        Case $msg = $Pic2
            _GuiCtrlStatusBar_SetText($Status1, "Pic2 Primary Down", 0)
            $DragCtrl = $Pic2
        Case $msg = $GUI_EVENT_PRIMARYUP
            _GuiCtrlStatusBar_SetText($Status1, "Primary Up", 0)
            saveSplitPos()
            _GuiCtrlStatusBar_SetText($Status1, "", 1)
            Select
                Case $DragCtrl = $Pic1
                    SplitterVert($TreeView1, $ListView1, $Pic1, $Pic2)
                    $DragCtrl = ""
                Case $DragCtrl = $Pic2
                    SplitterHort($TreeView1, $ListView1, $Edit1, $Pic2)
                    $DragCtrl = ""
            EndSelect

        Case $msg = $GUI_EVENT_SECONDARYDOWN
            _GuiCtrlStatusBar_SetText($Status1, "Secondary Down", 0)
        Case $msg = $GUI_EVENT_SECONDARYUP
            _GuiCtrlStatusBar_SetText($Status1, "Secondary Up", 0)
        Case $msg = $GUI_EVENT_MOUSEMOVE
            $stopTime = TimerInit()
            If $DragCtrl <> "" Then
                _GuiCtrlStatusBar_SetText($Status1, "Dragging", 1)
                Local $picpos = ControlGetPos("", "", $DragCtrl)
                Local $mousepos = MouseGetPos()
                Local $winpos = WinGetClientSize("")
                If $DragCtrl = $Pic1 Then
                    If $mousepos[0] > 25 And $mousepos[0] < ($winpos[0] - 25) Then GUICtrlSetPos($Pic1, $mousepos[0], $picpos[1], 2)
                EndIf
                If $DragCtrl = $Pic2 Then
                    If $mousepos[1] > 25 And $mousepos[1] < ($winpos[1] - 25) Then GUICtrlSetPos($Pic2, $picpos[0], $mousepos[1], $picpos[2], 2)
                EndIf
            Else
                _GuiCtrlStatusBar_SetText($Status1, "Mouse Move", 0)
            EndIf
        Case $msg = $GUI_EVENT_RESIZED Or $msg = $GUI_EVENT_MAXIMIZE Or $msg = $GUI_EVENT_RESTORE;!!!
            ResizeControls()
            saveSplitPos()

        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            $idleTime = TimerDiff($stopTime)
            If $idleTime > 100 Then
                $stopTime = TimerInit()
                If $DragCtrl <> "" Then
                    _GuiCtrlStatusBar_SetText($Status1, "Idling", 1)
                Else
                    _GuiCtrlStatusBar_SetText($Status1, "Idling", 0)
                EndIf
            EndIf
    EndSelect
WEnd
Exit

Func saveSplitPos()
    Local $winpos = WinGetClientSize("")
    $Form1Width = $winpos[0]
    $Form1Height = $winpos[1]
    Local $splitpos1 = ControlGetPos("", "", $Pic1)
    $leftVSplit = $splitpos1[0]
    Local $splitpos2 = ControlGetPos("", "", $Pic2)
    $topHSplit = $splitpos2[1]
EndFunc   ;==>saveSplitPos

Func RESIZE_CONTROLS($hWnd, $msg, $wParam, $lParam)
    Local $winpos = WinGetClientSize("")
    Local $Hcoef = ($winpos[0] - $leftMargin - $rigthMargin - $splitWidth) / ($Form1Width - $leftMargin - $rigthMargin - $splitWidth)
    Local $Vcoef = ($winpos[1] - $topMargin - $bottomMargin - $splitWidth - $statusBarHeight) / ($Form1Height - $topMargin - $bottomMargin - $splitWidth - $statusBarHeight)

    GUICtrlSetPos($Pic2, $leftMargin, $topMargin + ($topHSplit - $topMargin) * $Vcoef, $winpos[0])
    GUICtrlSetPos($Pic1, $leftMargin + ($leftVSplit - $leftMargin) * $Hcoef, $topMargin, $splitWidth, ($topHSplit - $topMargin) * $Vcoef)

    ResizeControls()
    Return $GUI_RUNDEFMSG
EndFunc   ;==>RESIZE_CONTROLS

Func ResizeControls()
    _GuiCtrlStatusBar_Resize($Status1)

    SplitterHort($TreeView1, $ListView1, $Edit1, $Pic2)
    SplitterVert($TreeView1, $ListView1, $Pic1, $Pic2)
EndFunc   ;==>ResizeControls

Func SplitterVert($ctrl1, $ctrl2, $split1, $iop)
    GUICtrlSetState($split1, $gui_hide);!!!
    Local $splitpos1 = ControlGetPos("", "", $split1)
    Local $winpos = WinGetClientSize("")

    GUICtrlSetPos($split1, $splitpos1[0], $splitpos1[1], $splitWidth, $splitpos1[3]);!!!

    GUICtrlSetPos($ctrl1, $leftMargin, $splitpos1[1], _
            ($splitpos1[0] - $leftMargin), _
            $splitpos1[3])

    GUICtrlSetPos($ctrl2, $splitpos1[0] + $splitWidth, _
            $splitpos1[1], _
            $winpos[0] - $rigthMargin - $splitpos1[0] - $splitWidth, _
            $splitpos1[3])
    GUICtrlSetState($split1, $gui_show);!!!
EndFunc   ;==>SplitterVert

Func SplitterHort($ctrl1, $ctrl2, $ctrl3, $split)
    Local $splitpos = ControlGetPos("", "", $split)
    Local $splitpic1 = ControlGetPos("", "", $Pic1);!!!
    $splitpos[3] = $splitWidth
    GUICtrlSetPos($split, $splitpos[0], $splitpos[1], $splitpos[2], $splitWidth);!!!
    GUICtrlSetState($split, $gui_hide);!!!

    Local $winpos = WinGetClientSize("")

    Local $nh
    $nh = $splitpos[1] - $topMargin;jcd - 9

    GUICtrlSetPos($ctrl1, $leftMargin, $topMargin, $splitpic1[0] - $leftMargin, $nh)
    GUICtrlSetPos($ctrl2, $splitpic1[0] + $splitWidth, $topMargin, $winpos[0] - $rigthMargin - ($splitpic1[0] + $splitWidth), $nh)

    Local $top = $splitpos[1] + $splitWidth
    GUICtrlSetPos($Pic1, $splitpic1[0], $splitpic1[1], $splitpic1[2], $nh);!!!

    $nh = $winpos[1] - $top - $bottomMargin - $statusBarHeight; move this up above the status bar

    GUICtrlSetPos($ctrl3, $leftMargin, _
            $top, _
            $winpos[0] - $leftMargin - $rigthMargin, _
            $nh)

    GUICtrlSetState($split, $gui_show);!!!
EndFunc   ;==>SplitterHort

Re: [R] Bonne question comment s'appelle cette fonction (GUI splitters)

Posté : jeu. 11 oct. 2018 03:01
par Anthony
Vraiment un grand merci à tous.
Reste plus qu'à essayer tout çà :D