Jump to content

Make a splitter


AZJIO
 Share

Recommended Posts

Pull for a red strip. Elements disappear.

The _GUICtrlListView_Create functions have to be required.

Updated the corrected example:

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
Global $hLV_Dubl

Opt("GUIOnEventMode", 1)
Opt("GUIResizeMode", 802)

$Gui = GUICreate('', 555, 444, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_POPUP + $WS_CLIPCHILDREN, $WS_EX_ACCEPTFILES + $WS_EX_COMPOSITED)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$hLV_Sourse = _GUICtrlListView_Create($Gui, ' ', 10, 25, 555 - 20, 95, BitOR($LVS_NOCOLUMNHEADER, $LVS_REPORT, $LVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE, True)
_GUICtrlListView_SetExtendedListViewStyle($hLV_Sourse, BitOR($LVS_EX_FULLROWSELECT, $LVS_OWNERDRAWFIXED))
_Dubl()

$ReLbl = GUICtrlCreateLabel('', 10, 120, 555 - 20, 3)
GUICtrlSetBkColor(-1, 0xff0000)
GUICtrlSetResizing(-1, 2 + 4 + 32 + 512)
GUICtrlSetCursor(-1, 11)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_ResizeField")
GUISetState()

While 1
    Sleep(10000)
WEnd

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Func _Dubl()
    $GuiPos = WinGetClientSize($Gui)
    $hLV_Dubl = _GUICtrlListView_Create($Gui, ' ', 10, 150, $GuiPos[0] - 20, $GuiPos[1] - 198, BitOR($LVS_NOCOLUMNHEADER, $LVS_REPORT, $LVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE, True)
    _GUICtrlListView_SetExtendedListViewStyle($hLV_Dubl, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_OWNERDRAWFIXED))
    _GUICtrlListView_SetBkColor($hLV_Dubl, 0xf0f0f0)
EndFunc   ;==>_Dubl

Func _ResizeField()
    Local $aClientSize, $aCur_Info, $aID_Pos, $dY, $tmp
    $aCur_Info = GUIGetCursorInfo($Gui)
    If $aCur_Info[4] = $ReLbl Then
        $aID_Pos = ControlGetPos($Gui, '', $ReLbl)
        $aClientSize = WinGetClientSize($Gui)
        $aClientSize[1] -= 60

        ; высчитываем разницу координат
        $dY = $aID_Pos[1] - $aCur_Info[1]
        While 1
            Sleep(10)
            $aCur_Info = GUIGetCursorInfo($Gui) ; получаем новую инфу
            $aCur_Info[1] += $dY
            
            If Not ($aCur_Info[1] < 60 Or $aClientSize[1] - $aCur_Info[1] < 60 Or $tmp = $aCur_Info[1]) Then
                GUICtrlSetPos($ReLbl, 10, $aCur_Info[1]) ; устанавливаем новые координаты

                _WinAPI_MoveWindow($hLV_Sourse, 10, 25, $aID_Pos[2], $aCur_Info[1] - 25)
                _WinAPI_MoveWindow($hLV_Dubl, 10, $aCur_Info[1] + 30, $aID_Pos[2], $aClientSize[1] - $aCur_Info[1] - 18)
                $tmp = $aCur_Info[1]
            EndIf
            If Not $aCur_Info[2] Then ExitLoop ; выход если курсор отпущен
        WEnd
    EndIf
EndFunc   ;==>_ResizeField
Edited by AZJIO
Link to comment
Share on other sites

I would use controlIDs and commands like GUICtrlSetPos to that kind of resizing. Then I know that the x- and y-coordinates are relative to the GUI:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt( "GUIOnEventMode", 1 )

$width  = 555 ; Width of GUI
$height = 444 ; Height of GUI

$hGui = GUICreate( "", $width, $height, -1, -1 )
GUISetOnEvent( $GUI_EVENT_CLOSE, "Stop" )

Local $hSource = 95, $hSpace = 25 ; Height of source and space
$idSource = GUICtrlCreateListView( "", 10, $hSpace, $width - 20, $hSource )
$idDubl = GUICtrlCreateListView( "", 10, 2*$hSpace + $hSource, $width - 20, $height - $hSource - 3*$hSpace )

$idSplitter = GUICtrlCreateLabel( "", 10, $hSpace + $hSource + ( $hSpace - 3 ) / 2, $width - 20, 3 )
; y = $hSpace + $hSource + ( $hSpace - 3 ) / 2 => $hSource = y - $hSpace - ( $hSpace - 3 ) / 2
GUICtrlSetBkColor( -1, 0xff0000 )
GUICtrlSetCursor( -1, 11 )

GUISetOnEvent( $GUI_EVENT_PRIMARYDOWN, "ResizeField" )

GUISetState()

While 1
    Sleep(10)
WEnd

Func Stop()
    Exit
EndFunc

Func ResizeField()
    Local $aCurInfo = GUIGetCursorInfo( $hGui ), $hSource
    If $aCurInfo[4] = $idSplitter Then
        While $aCurInfo[2]
            GUICtrlSetPos( $idSplitter, 10, $aCurInfo[1] )
            ; $hSource = y - $hSpace - ( $hSpace - 3 ) / 2 ; The formula above
            $hSource = $aCurInfo[1] - $hSpace - ( $hSpace - 3 ) / 2 ; y = $aCurInfo[1]
            GUICtrlSetPos( $idSource, 10, $hSpace, $width - 20, $hSource ) ; Compare with the creation of $idSource above
            GUICtrlSetPos( $idDubl, 10, 2*$hSpace + $hSource, $width - 20, $height - $hSource - 3*$hSpace ) ; Compare with the creation of $idDubl above
            $aCurInfo = GUIGetCursorInfo( $hGui )
            Sleep(10)
        WEnd
    EndIf
EndFunc
Link to comment
Share on other sites

Here is an example of the _WinAPI_MoveWindow function. The _GUICtrlListView_Create functions have to be required.

AutoIt3 functions use _GUICtrlListView_SetItemParam, to store the ID. I'm in my script, use these values for the connection of multiple arrays and indexes.

_GUICtrlListView_SetItemParam($hLV_Sourse, $idx, _WinAPI_MakeLong(3, $i))
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIRichEdit.au3>
OnAutoItExitRegister("Error")
Global $iWidth = 500, $iHeight = 130

$hForm = GUICreate('Test', $iWidth, $iHeight + 20, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_THICKFRAME, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_TABSTOP), $WS_EX_COMPOSITED)
$hR_Edit1 = _GUICtrlRichEdit_Create($hForm, 'Edit1', 10, 10, 290, 130)
$hR_Edit2 = _GUICtrlRichEdit_Create($hForm, 'Edit2', 304, 10, 180, 130)
$Label = GUICtrlCreateLabel('', 300, 10, 4, 130)
; GUICtrlSetBkColor(-1, 0xffd7d7)
GUICtrlSetCursor(-1, 13)
$dd = 300 / $iWidth

GUISetState()
GUIRegisterMsg($WM_SIZE, "WM_SIZE")

While 1
    $nMsg = GUIGetMsg()

    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            Exit
        Case -7
            $aCur_Info = GUIGetCursorInfo($hForm)
            If $aCur_Info[4] = $Label Then
                $aID_Pos = ControlGetPos($hForm, '', $Label)
                ; высчитываем разницу координат
                $dX = $aID_Pos[0] - $aCur_Info[0]
                $tmp = 0
                While 1
                    Sleep(10)
                    $aCur_Info = GUIGetCursorInfo($hForm) ; получаем новую инфу
                    $aCur_Info[0] += $dX

                    If Not ($aCur_Info[0] - 10 < 40 Or $iWidth - $aCur_Info[0] - 20 < 40 Or $tmp = $aCur_Info[0]) Then
                        GUICtrlSetPos($Label, $aCur_Info[0], 10) ; устанавливаем новые координаты
                        _WinAPI_MoveWindow($hR_Edit1, 10, 10, $aCur_Info[0] - 10, $iHeight)
                        _WinAPI_MoveWindow($hR_Edit2, $aCur_Info[0] +4, 10, $iWidth - $aCur_Info[0] - 20, $iHeight)
                        $tmp = $aCur_Info[0]
                    EndIf
                    If Not $aCur_Info[2] Then ExitLoop ; выход если курсор отпущен
                WEnd
                $dd = $aCur_Info[0] / $iWidth
            EndIf
    EndSwitch
WEnd

Func WM_SIZE($hWnd, $Msg, $wParam, $lParam)
    $iWidth = _WinAPI_LoWord($lParam)
    $iHeight = _WinAPI_HiWord($lParam) - 20
    Local $w = Int($iWidth * $dd)
    _WinAPI_MoveWindow($hR_Edit1, 10, 10, $w - 10, $iHeight)
    _WinAPI_MoveWindow($hR_Edit2, $w + 4, 10, $iWidth - $w - 20, $iHeight)
    GUICtrlSetPos($Label, $w + 2, 10, 10, $iHeight - 20)
    Return $GUI_RUNDEFMSG
EndFunc

Func Error()
    GUIDelete()
EndFunc
Edited by AZJIO
Link to comment
Share on other sites

AZJIO,

your _WinAPI_MoveWindow() calculation are wrong and that's the reason why the controls disappear.

My brain doesn't work properly at this time to deliver you a solution - maybe tomorrow.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

UEZ

I simplified an example, there are no calculations.

#include <GuiRichEdit.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>

OnAutoItExitRegister("Error")
Opt("GUIOnEventMode", 1)

$Gui = GUICreate('', 555, 444, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_POPUP + $WS_CLIPCHILDREN, $WS_EX_ACCEPTFILES)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$hLV_Sourse = _GUICtrlListView_Create($Gui, ' ', 10, 25, 555 - 20, 95, BitOR($LVS_NOCOLUMNHEADER, $LVS_REPORT, $LVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE, True)
_GUICtrlListView_SetExtendedListViewStyle($hLV_Sourse, BitOR($LVS_EX_FULLROWSELECT, $LVS_OWNERDRAWFIXED))
$hR_Edit1 = _GUICtrlRichEdit_Create($Gui, 'Edit1', 10, 210, 290, 130)
GUISetState()
Sleep(1500)
_WinAPI_MoveWindow($hR_Edit1, 110, 240, 110, 111)
_WinAPI_MoveWindow($hLV_Sourse, 3, 2, Default, 333)

While 1
    Sleep(10000)
WEnd

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Func Error()
    GUIDelete()
EndFunc
Edited by AZJIO
Link to comment
Share on other sites

Ok, my brain worked a little bit right now. 

Try this function:

Func _ResizeField()
    Local $aClientSize, $aCur_Info, $aID_Pos, $dX, $tmp
    $aCur_Info = GUIGetCursorInfo($Gui)
    ; $iLV_Sourse = _WinAPI_GetDlgCtrlID($hLV_Sourse)
    ; $iLV_Dubl = _WinAPI_GetDlgCtrlID($hLV_Dubl)
    ; MsgBox(0, '?????????', $iLV_Sourse &@CRLF& $iLV_Dubl )
    If $aCur_Info[4]=$ReLbl Then
        $aID_Pos = ControlGetPos($Gui, '', $ReLbl)
        $aClientSize = WinGetClientSize($Gui)
        $aClientSize[0] -=60
        $aSize1 = ControlGetPos($Gui, "", $hLV_Sourse)
        $aSize2 = ControlGetPos($Gui, "", $hLV_Dubl)
        ; ??????????? ??????? ?????????
        $dX= $aID_Pos[1]-$aCur_Info[1]
        While 1
            Sleep(10)
            $aCur_Info = GUIGetCursorInfo($Gui) ; ???????? ????? ????
            $aCur_Info[0]+=$dX
            If Not($aCur_Info[1]<60 Or $aClientSize[1]-$aCur_Info[1]<60 Or $tmp = $aCur_Info[1]) Then
                $aID_Pos = ControlGetPos($Gui, '', $ReLbl)
                GUICtrlSetPos($ReLbl, 10, $aCur_Info[1]) ; ????????????? ????? ??????????
                ; GUICtrlSetPos($iLV_Sourse, 10, 25, Default, $aCur_Info[1])
                ; GUICtrlSetPos($iLV_Dubl, 10, $aCur_Info[1], Default, $aClientSize[1]-$aCur_Info[1]-4)

                _WinAPI_MoveWindow($hLV_Sourse, 10, 25, $aSize1[2], $aSize2[3] + ($aID_Pos[1] - 270), 1)
                _WinAPI_MoveWindow($hLV_Dubl, 10, $aID_Pos[1] + 30, $aSize2[2], $aSize2[3] - ($aID_Pos[1] - 120), 1)
                ; _WinAPI_SetWindowPos($hLV_Sourse, $HWND_BOTTOM, 10, 25, Default, $aCur_Info[1], $SWP_SHOWWINDOW + $SWP_NOSENDCHANGING)
                ; _WinAPI_SetWindowPos($hLV_Dubl, $HWND_BOTTOM, 10, $aCur_Info[1], Default, $aClientSize[1]-$aCur_Info[1]-4, $SWP_SHOWWINDOW + $SWP_NOSENDCHANGING)


                ; GUICtrlSetPos($TreeView, 0, 35, $aCur_Info[1], $aClientSize[0])
                ; GUICtrlSetPos($ListView, $aCur_Info[1]+4, 35, $aClientSize[1]-$aCur_Info[1]-4, $aClientSize[0])
                $tmp = $aCur_Info[1]
            EndIf
            If Not $aCur_Info[2] Then ExitLoop ; ????? ???? ?????? ???????
        WEnd
        ; GUISetState(@SW_HIDE)
        ; GUISetState(@SW_SHOW)
        ; WinMove($Gui, '', Default, Default, $XYPos[0], $XYPos[1])
        ; _WinAPI_RedrawWindow($Gui, 0, 0, BitOR($RDW_INVALIDATE, $RDW_UPDATENOW))
        ; _WinAPI_ShowWindow($hLV_Sourse, @SW_HIDE)
        ; _WinAPI_ShowWindow($hLV_Sourse, @SW_SHOW)
    EndIf
EndFunc

It is not made for resizing the GUI, only for the controls.

Does it help you?

 

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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