Jump to content

How to make child not movable but still resizeable? Any (Ex)Style or UDF for this?


E1M1
 Share

Recommended Posts

How do I...

1)Lock Files window at left side, but still allow user to resize it?

2)Lock Logs window at bottom, but still allow user change it's height?

3)Auto resize child windows when main window is resized OR when 1 of child window is resized (ex: resize Files window when Logs window size is changed) to make windows best fit in parent?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#include <StaticConstants.au3>
#Region ### START Koda GUI section ### Form=
$w = 800
$Form1 = GUICreate("* Configuration Manager", $w, 600,Default,Default,BitOR($WS_CLIPCHILDREN,$WS_CLIPSIBLINGS,$WS_BORDER,$WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_SYSMENU))
$File = GUICtrlCreateMenu("File")
$openraconf = GUICtrlCreateMenuItem("Open * configuration", $File)
$SaveRaConf = GUICtrlCreateMenuItem("Save * configuration", $File)
$SaveRaConfAS = GUICtrlCreateMenuItem("Save * configuration AS", $File)
$Openas = GUICtrlCreateMenuItem("Open custom  * configuration", $File)
$Exit = GUICtrlCreateMenuItem("Exit", $File)
$Run = GUICtrlCreateMenu("Run")
$Ru = GUICtrlCreateMenuItem("Run", $Run)
$Pause = GUICtrlCreateMenuItem("Pause", $Run)
$Stop = GUICtrlCreateMenuItem("Stop", $Run)
$Tools = GUICtrlCreateMenu("Tools")
$WindowInfo = GUICtrlCreateMenuItem("Window title grabber", $Tools)
$Options = GUICtrlCreateMenuItem("Options", $Tools)
$Help = GUICtrlCreateMenu("Help")
$Documentation = GUICtrlCreateMenuItem("Documentation", $Help)
$About = GUICtrlCreateMenuItem("About", $Help)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


$hFiles = GUICreate("Files", 200, 300,0,0,$WS_CHILD+$WS_THICKFRAME+$WS_CAPTION,$WS_EX_TOOLWINDOW,$Form1)

$treeview = GUICtrlCreateTreeView(0, 0, 200, 320, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$generalitem = GUICtrlCreateTreeViewItem("*", $treeview)
$mainprogram = GUICtrlCreateTreeViewItem("Main Program", $generalitem)
GUICtrlSetColor(-1, 0x0000C0)
$plugins = GUICtrlCreateTreeViewItem("Plugins", $generalitem)
GUICtrlSetColor(-1, 0x0000C0)
$aboutitem = GUICtrlCreateTreeViewItem("About", $mainprogram)
$compitem = GUICtrlCreateTreeViewItem("Computer", $mainprogram)
$useritem = GUICtrlCreateTreeViewItem("User", $mainprogram)
GUICtrlSetState($generalitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "General"-item and paint in bold
GUISetState()

$hLog = GUICreate("Logs", $w, 320,0,320,BitOR($WS_CHILD,$WS_THICKFRAME,$WS_CAPTION),$WS_EX_TOOLWINDOW,$Form1)
$tab = GUICtrlCreateTab(0, 0, $w, 320)
$tab0 = GUICtrlCreateTabItem("Main")
$tab1 = GUICtrlCreateTabItem("Plugins")

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Thanks in advance.

Edited by E1M1

edited

Link to comment
Share on other sites

How do I...

1)Lock Files window at left side, but still allow user to resize it?

#include <GUIConstantsEx.au3>
#include <windowsconstants.au3>
Const $SC_MOVE = 0xF010

$gui = GUICreate("Stuck Here",-1,-1,0,0,BitOr($GUI_SS_DEFAULT_GUI,$WS_SIZEBOX))
GUISetState()
GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")
winsetontop($gui,"",1)
While GUIGetMsg() <> -3
WEnd
GUIDelete($gui)

Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    If BitAND($wParam, 0xFFF0) = $SC_MOVE Then Return False

    Return $GUI_RUNDEFMSG
EndFunc

You could adapt this for Q2 as well.

Q3 - here is an example

#include <GuiConstants.au3>
#include <windowsconstants.au3>

Const $SM_CXFIXEDFRAME = 7
Global Const $WM_ENTERSIZEMOVE = 0x231,$WM_EXITSIZEMOVE = 0x232
Global $guiWid = 500, $Guiht = 500
;Global Const $WS_EX_COMPOSITED = 0x2000000
$Main_GUI = GUICreate("Main", 500, 500, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_CLIPSIBLINGS),$WS_EX_COMPOSITED);, $WS_EX_LAYERED);$WS_POPUP + $WS_SYSMENU + $WS_MINIMIZEBOX
;$gamegui = GUICreate("QBC", 1280, 1024, -1, -1, $WS_POPUP + $WS_SYSMENU + $WS_MINIMIZEBOX, $WS_EX_LAYERED)
GUISetBkColor(0xfffaf0, $Main_GUI)
GUISetState(@SW_SHOW, $Main_GUI)
$Btn_Exit = GUICtrlCreateButton("E&xit", 10, 10, 90, 20)
GUICtrlSetResizing(-1,BitOr($Gui_DOCKTOP,$GUI_DOCKLEFT,$GUI_DOCKWIDTH,$GUI_DOCKHEIGHT))

$wtitle = DllCall('user32.dll', 'int', 'GetSystemMetrics', 'int', $SM_CYCAPTION)
$wtitle = $wtitle[0]
$wside = DllCall('user32.dll', 'int', 'GetSystemMetrics', 'int', $SM_CXFIXEDFRAME)
$wside = $wside[0]
$childHt = ($GuiHt - 50)/2 - $wtitle - 2* $wside
$childWid = $GuiWid/2 - 2 * $wside

$Child1_GUI = GUICreate("Child1",$childWid, $childHt, 0, 50, $WS_CAPTION);,$WS_EX_LAYERED)
GUISetBkColor(0xffffff, $Child1_GUI)
$Btn_Test = GUICtrlCreateButton("Test", 10, 10, 90, 20)
DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Child1_GUI), "hwnd", WinGetHandle($Main_GUI))
GUISetState(@SW_SHOW, $Child1_GUI)

$Child2_GUI = GUICreate("Child2", $childWid, $childHt, $GuiWid/2, 50);, $WS_POPUP)
GUISetBkColor(0x0ff0000, $Child2_GUI)
GUISetState($Child2_GUI)
DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Child2_GUI), "hwnd", WinGetHandle($Main_GUI))
GUISetState(@SW_SHOW, $Child2_GUI)

$Child3_GUI = GUICreate("Child3", $childWid, $childHt, 0, 50 + $childHt + 2*$wside + $wtitle, $WS_CAPTION);,$WS_EX_LAYERED)
GUISetBkColor(0x00ff00, $Child3_GUI)
DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Child3_GUI), "hwnd", WinGetHandle($Main_GUI))
GUISetState(@SW_SHOW, $Child3_GUI)

$Child4_GUI = GUICreate("Child4", $childWid, $childHt, $GuiWid/2, 50 +$childHt + 2*$wside + $wtitle);, $WS_POPUP)
GUISetBkColor(0x00000ff, $Child4_GUI)
DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Child4_GUI), "hwnd", WinGetHandle($Main_GUI))
GUISetState(@SW_SHOW, $Child4_GUI)

GuiSwitch($Main_GUI)
GUIRegisterMsg($WM_SIZE, "SetChildrenToBed")

Opt("mousecoordmode", 2)
$winact = ''

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $Btn_Exit
            Exit
        Case $Btn_Test
            MsgBox(0, "Test", "Hit Button on Child Window")
    EndSwitch


WEnd

Func SetChildrenToBed($hWnd,$iMsg,$wparam,$lparam)
    Local $clientHt = BitAnd($lparam,0xffff)
    Local $clientWid = BitShift($lparam,16)
    WinMove($Child1_GUI,"",0,50,$clientHt/2,($clientWid-50)/2)
    WinMove($Child2_GUI,"",$clientHt/2,50,$clientHt/2,($clientWid-50)/2)
    WinMove($Child3_GUI,"",0,50 + ($clientWid-50)/2,$clientHt/2,($clientWid-50)/2)
    WinMove($Child4_GUI,"",$clientHt/2,50 + ($clientWid-50)/2,$clientHt/2,($clientWid-50)/2)
EndFunc
Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Thanks, only 1 question. How to make it not lock main window? I want lock only child, but have parent still movable.

Isn't here any window splitter that would allow user split window parts, and then make your mouse liik like resizing arrow when you move on split control?

Edited by E1M1

edited

Link to comment
Share on other sites

  • Moderators

E1M1.

Ans 1. Check the value of hWnd in the message handler and only action the $SC_MOVE check if it is the child that has sent the message. ;)

Ans 2. Check the GUIFrames UDF in my sig. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

E1M1,

As explained in the GUIRegisterMsg tutorial in the Wiki, the $hWnd parameter is the handle of the GUI sending the message. So you need to check if it is the GUI you wish to remain static that is sending the SC_MOVE message you are intercepting and not another one. Here is a short script to show you want I mean:

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

Global Const $SC_MOVE = 0xF010

$hGUI_1 = GUICreate("Moveable", 500, 500, 100, 100)
GUISetState()

$hGUI_2 = GUICreate("Static", 500, 500, 300, 300)
GUISetState()

GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd
Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)

    If $hWnd = $hGUI_2 Then ; Only check for SC_MOVE if it is the window we do NOT want to move
        If BitAND($wParam, 0xFFF0) = $SC_MOVE Then Return False ; And only intercept the SC_MOVE message
    EndIf

    Return $GUI_RUNDEFMSG
    
EndFunc

If you are going to use message handlers, you need to understand what is going on inside them - the tutorial will help a lot. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Grr I cant use childs together with GUIFrames. I just dont see my childs after i create GUIFrame. Any solution?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#include <StaticConstants.au3>
#include <GUIFrame.au3>
Const $SC_MOVE = 0xF010

#Region ### START Koda GUI section ### Form=
$w = 800
$Form1 = GUICreate("* Configuration Manager", $w, 600,Default,Default,BitOR($WS_CLIPCHILDREN,$WS_CLIPSIBLINGS,$WS_BORDER,$WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_SYSMENU))
$File = GUICtrlCreateMenu("File")
$openraconf = GUICtrlCreateMenuItem("Open * configuration", $File)
$SaveRaConf = GUICtrlCreateMenuItem("Save * configuration", $File)
$SaveRaConfAS = GUICtrlCreateMenuItem("Save * configuration AS", $File)
$Openas = GUICtrlCreateMenuItem("Open custom  * configuration", $File)
$Exit = GUICtrlCreateMenuItem("Exit", $File)
$Run = GUICtrlCreateMenu("Run")
$Ru = GUICtrlCreateMenuItem("Run", $Run)
$Pause = GUICtrlCreateMenuItem("Pause", $Run)
$Stop = GUICtrlCreateMenuItem("Stop", $Run)
$Tools = GUICtrlCreateMenu("Tools")
$WindowInfo = GUICtrlCreateMenuItem("Window title grabber", $Tools)
$Options = GUICtrlCreateMenuItem("Options", $Tools)
$Help = GUICtrlCreateMenu("Help")
$Documentation = GUICtrlCreateMenuItem("Documentation", $Help)
$About = GUICtrlCreateMenuItem("About", $Help)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$iFrame_A = _GUIFrame_Create($Form1,1,5,0,0,0,0,0,0)
; Set min sizes for the frames
_GUIFrame_SetMin($iFrame_A, 100, 100)
; Switch to first (left) frame of Frame_A
_GUIFrame_Switch($iFrame_A, 1)


$hFiles = GUICreate("Files", 200, 300,0,0,BitOR($WS_CHILD,$WS_THICKFRAME,$WS_CAPTION,$WS_DLGFRAME),$WS_EX_TOOLWINDOW,$Form1)

$treeview = GUICtrlCreateTreeView(0, 0, 200, 320, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS) )
$generalitem = GUICtrlCreateTreeViewItem("*", $treeview)
$mainprogram = GUICtrlCreateTreeViewItem("Main Program", $generalitem)
GUICtrlSetColor(-1, 0x0000C0)
$plugins = GUICtrlCreateTreeViewItem("Plugins", $generalitem)
GUICtrlSetColor(-1, 0x0000C0)
$aboutitem = GUICtrlCreateTreeViewItem("About", $mainprogram)
$compitem = GUICtrlCreateTreeViewItem("Computer", $mainprogram)
$useritem = GUICtrlCreateTreeViewItem("User", $mainprogram)
GUICtrlSetState($generalitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "General"-item and paint in bold
GUISetState()

$hLog = GUICreate("Logs", $w, 320,0,320,BitOR($WS_CHILD,$WS_THICKFRAME,$WS_CAPTION),$WS_EX_TOOLWINDOW,$Form1)

$tab = GUICtrlCreateTab(0, 0, $w, 320)
$tab0 = GUICtrlCreateTabItem("Main")
$tab1 = GUICtrlCreateTabItem("Plugins")
GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _GUIFrame_Exit()
            Exit

    EndSwitch
WEnd

Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    If BitAND($wParam, 0xFFF0) = $SC_MOVE Then Return False

    Return $GUI_RUNDEFMSG
EndFunc

edited

Link to comment
Share on other sites

  • Moderators

E1M1,

Any solution?

Of course - just make the GUIs children of the frame GUIs like this: ;)

$iFrame_A = _GUIFrame_Create($Form1, 1, 5, 0, 0, 0, 0, 0, 0)
; Set min sizes for the frames
_GUIFrame_SetMin($iFrame_A, 100, 100)

; Get handle to top frame
$hTop_Frame = _GUIFrame_GetHandle($iFrame_A, 1)

$hFiles = GUICreate("Files", 200, 300, 0, 0, BitOR($WS_CHILD, $WS_THICKFRAME, $WS_CAPTION, $WS_DLGFRAME), $WS_EX_TOOLWINDOW, $hTop_Frame)

;.....

; Get handle to bottom frame
$hBot_Frame = _GUIFrame_GetHandle($iFrame_A, 2)

$hLog = GUICreate("Logs", $w, 320, 0, 0, BitOR($WS_CHILD, $WS_THICKFRAME, $WS_CAPTION), $WS_EX_TOOLWINDOW, $hBot_Frame)

; .....

Is that what you wanted? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

E1M1,

are frames standalone GUIs? I always thought it'swindow element like button or something

In this UDF they are indeed stand-alone GUIs - as it clearly states in the first post of the GUIFrames thread: ;)

The frames themselves are normal AutoIt GUIs. You can colour them and create controls within them just as you would in any other script.

Frames in other apps might well be different, of course. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Why does this make window resizing impossible?

GUIRegisterMsg($WM_SIZE, "SetChildrenToBed")

Func SetChildrenToBed($hWnd, $Msg, $wParam, $lParam)
        $pos = WinGetPos($Form1)
        WinMove($hLog,"",0,320,$pos[2],200)
        Return $GUI_RUNDEFMSG
EndFunc   ;==>On_WM_SYSCOMMAND

What WM message I could use to get wether GUIFrame changed GUI?

edited

Link to comment
Share on other sites

Some questions:

1) I want to have vertical splitter (Frame) next to GUICtrlCreateTreeView, not at the middle of GUI (as it is now).

2) How do make frame that contains Tabs maintain it's heght in pixels on GUI resize? currently it gets messed if you make window small and then large again.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#include <StaticConstants.au3>
#include <GUIFrame.au3>
Const $SC_MOVE = 0xF010
;~ Const $SC_SIZE = 0xF000

#Region ### START Koda GUI section ### Form=
$w = 800
$Form1 = GUICreate("* Configuration Manager", $w, 600, Default, Default, BitOR($WS_CLIPCHILDREN, $WS_CLIPSIBLINGS, $WS_BORDER, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_SYSMENU))
$File = GUICtrlCreateMenu("File")
$openraconf = GUICtrlCreateMenuItem("Open * configuration", $File)
$SaveRaConf = GUICtrlCreateMenuItem("Save * configuration", $File)
$SaveRaConfAS = GUICtrlCreateMenuItem("Save * configuration AS", $File)
$Openas = GUICtrlCreateMenuItem("Open custom  * configuration", $File)
$Exit = GUICtrlCreateMenuItem("Exit", $File)
$Run = GUICtrlCreateMenu("Run")
$Ru = GUICtrlCreateMenuItem("Run", $Run)
$Pause = GUICtrlCreateMenuItem("Pause", $Run)
$Stop = GUICtrlCreateMenuItem("Stop", $Run)
$Tools = GUICtrlCreateMenu("Tools")
$WindowInfo = GUICtrlCreateMenuItem("Window title grabber", $Tools)
$Options = GUICtrlCreateMenuItem("Options", $Tools)
$Help = GUICtrlCreateMenu("Help")
$Documentation = GUICtrlCreateMenuItem("Documentation", $Help)
$About = GUICtrlCreateMenuItem("About", $Help)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$iFrame_A = _GUIFrame_Create($Form1,1)
; Set min sizes for the frames
_GUIFrame_SetMin($iFrame_A, 100, 100)
; Switch to first (left) frame of Frame_A
_GUIFrame_Switch($iFrame_A, 1)
_GUIFrame_ResizeSet($iFrame_A)

$iFrame_F = _GUIFrame_Create(_GUIFrame_GetHandle($iFrame_A, 1))
_GUIFrame_Switch($iFrame_F, 1)
$treeview = GUICtrlCreateTreeView(0, 0, 200, 320, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS))
;~ GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM+$GUI_DOCKWIDTH)
$generalitem = GUICtrlCreateTreeViewItem("*", $treeview)
$mainprogram = GUICtrlCreateTreeViewItem("Main Program", $generalitem)
GUICtrlSetColor(-1, 0x0000C0)
$plugins = GUICtrlCreateTreeViewItem("Plugins", $generalitem)
GUICtrlSetColor(-1, 0x0000C0)
$aboutitem = GUICtrlCreateTreeViewItem("About", $mainprogram)
$compitem = GUICtrlCreateTreeViewItem("Computer", $mainprogram)
$useritem = GUICtrlCreateTreeViewItem("User", $mainprogram)
GUICtrlSetState($generalitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "General"-item and paint in bold
_GUIFrame_Switch($iFrame_A, 2)

$tab = GUICtrlCreateTab(0, 0, $w, 320)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM+ $GUI_DOCKTOP)
$tab0 = GUICtrlCreateTabItem("Main")
$tab1 = GUICtrlCreateTabItem("Plugins")

_GUIFrame_ResizeSet()
_GUIFrame_ResizeReg()
;~ _GUIFrame_Switch($iFrame_A, 1)
;~
;~

GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _GUIFrame_Exit()
            Exit
    EndSwitch
WEnd

Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    If $hWnd <> $Form1 Then
        If BitAND($wParam, 0xFFF0) = $SC_MOVE Then Return False

        Return $GUI_RUNDEFMSG
    EndIf
EndFunc   ;==>On_WM_SYSCOMMAND

Func SetChildrenToBed($hWnd, $Msg, $wParam, $lParam)
        $pos = WinGetPos($Form1)
;~      WinMove($hLog,"",0,320,$pos[2])
        Return $GUI_RUNDEFMSG
EndFunc   ;==>On_WM_SYSCOMMAND

edited

Link to comment
Share on other sites

  • Moderators

E1M1,

Perhaps if you actually tried doing something yourself like reading the GUIFrames topic and the UDF headers you would not need to ask so many questions! :)

Why does this make window resizing impossible?

It quite clearly says in the topic that:

"The UDF uses the WM_SIZE message sent by the original GUIs to determine when to resize frames. If you want to register the same message within your script, you can still use this UDF. All you have to do is call a specific UDF function within your own message handler"

and in the UDF header that:

"If the script already has a WM_SIZE handler then do NOT use _GUIFrame_ResizeReg, but call _GUIFrame_SIZE_Handler from within it"

If you code your script following those guidelines you will find that the UDF will work correctly and the frames will resize. ;)

I want to have vertical splitter (Frame) next to GUICtrlCreateTreeView, not at the middle of GUI (as it is now).

Then I suggest you write your own UDF as this one puts the separator in the middle. :)

Perhaps if you were to do what your mother used to tell you and say "Could you please" or "Do you think you could possibly make a change" or something along those lines when asking I might just try and code a new version where you can specify the initial position of the separator.... ;)

How do make frame that contains Tabs maintain it's heght in pixels on GUI resize?

Are you saying that you want the frame never to exceed its intial size, even if the GUI is made larger? If so, that would need a new function (_GUIFrame_SetMax or something along those lines) and would mean a pretty major rewrite of the UDF - which I am not really that interested in doing at present. :shocked:

So that gives you 1.5 positive responses for your 3 questions. Not bad in my opinion. :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks.

Sorry if I was less or more impolite somewhere in this topic. English is not my first language, and I might not know all the expressions. All suggestions about my language are welcome. I'll Promise I'll use more "Could you please" or "Do you think you could possibly make a change". But look at bright side, now I know how to politely ask someone to change my broken code. You don't need to rewrite your UDF I will see what and how I can do. Rewriting UDF is great work. I know.

Thanks again for teaching me ask help properly.

edited

Link to comment
Share on other sites

  • Moderators

E1M1,

Here is a version of the UDF which allows you to set the initial position of the separator as you wished and an example to show it working. ;)

UDF first:

#include-once
; #INDEX# ============================================================================================================
; Title .........: GUIFrame
; AutoIt Version : 3.3 +
; Language ......: English
; Description ...: Splits GUI into slideable and resizable 2 part frames
; Remarks .......: - The user must call _GUIFrame_Exit on exit to delete subclassed separator bars to the
;                  UDF created WndProc and to release the Callback.
;                  - Only 2 levels of frames supported
;                  - If the script already has a WM_SIZE handler then do NOT use _GUIFrame_ResizeReg, but call
;                  _GUIFrame_SIZE_Handler from within it
; Author ........: Original UDF by Kip
; Modified ......; This version by Melba23
; ====================================================================================================================

;#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

; #INCLUDES# =========================================================================================================
#include <WinAPI.au3>

; #GLOBAL VARIABLES# =================================================================================================

; Array to hold handles for each frame set
Global $aGF_HandleIndex[1][7]
; [0][0] = 0 ; Count of frames      [0][1] = Move registered flag
; [n][0] = Parent GUI handle        [n][4] = Original GUI handle
; [n][1] = First frame handle       [n][5] = Indices of first frame internal frames
; [n][2] = Second frame handle      [n][6] = Indices of second frame internal frames
; [n][3] = Separator bar handle

; Array to hold sizing percentages for each frame set
Global $aGF_SizingIndex[1][6]
; [n][0] = First frame min      [n][2] = X coord    [n][4] = Width
; [n][1] = Second frame min     [n][3] = Y coord    [n][5] = Height

; Array to hold other settings for each frame set
Global $aGF_SettingsIndex[1][3]
; [n][0] = Separator orientation (vert/horz = 0/1)
; [n][1] = Resizable frame flag (0/1)
; [n][2] = Separator size (default = 5)

; Array to hold WinProc handles for each separator
Global $aGF_SepProcIndex[1][2] = [[0, 0]]

; Store registered Callback handle
Global $hGF_RegCallBack = DllCallbackRegister("_GUIFrame_SepWndProc", "int", "hwnd;uint;wparam;lparam")
$aGF_SepProcIndex[0][1] = DllCallbackGetPtr($hGF_RegCallBack)

; #CURRENT# ==========================================================================================================
; _GUIFrame_Create:       Splits a GUI into 2 frames
; _GUIFrame_SetMin:       Sets minimum sizes for frames
; _GUIFrame_ResizeSet:    Sets resizing flag for all or specified frames
; _GUIFrame_ResizeReg:    Registers WM_MOVE mesasge for resizing
; _GUIFrame_SIZE_Handler: Used to resize frames when a top-level GUI is resized
; _GUIFrame_GetHandle:    Returns the handle of a frame element (required for further splitting)
; _GUIFrame_Switch:       Sets a frame element as current GUI
; _GUIFrame_Exit:         Deletes all subclassed separator bars to free UDF WndProc and frees registered callback handle
; ====================================================================================================================

; #INTERNAL_USE_ONLY#=================================================================================================
; _GUIFrame_SepSubClass:      Sets new WndProc for frame separator bar
; _GUIFrame_SepWndProc:    New WndProc for frame separator bar
; _GUIFrame_SepPassMsg:    Passes Msg to original WndProc for action
; _GUIFrame_Move:          Moves and resizes frame elements and separator bars
; _GUIFrame_AdjIntFrames:  Moves and resizes internal frame elements when parent frame is resized
; ====================================================================================================================

; #FUNCTION# =========================================================================================================
; Name...........: _GUIFrame_Create
; Description ...: Splits a GUI into 2 frames
; Syntax.........: _GUIFrame_Create($hWnd, $iSepOrient = 0, $iSepSize = 5, $iX = 0, $iY = 0, $iWidth = 0, $iHeight = 0, $iStyle = 0, $iExStyle = 0, $iInit_Pos = 0)
; Parameters ....: $hWnd - Handle of GUI to split
;                  $iSepOrient - Orientation of separator bar: 0 = Vertical (default), 1 = Horizontal
;                  $iSepSize - Size of separator bar (default = 5, min = 3, max = 9)
;                  $iX - Left of frame area (default = 0)
;                  $iY - Top of frame area (default = 0)
;                  $iWidth - Width of frame area (default = full width)
;                  $iHeight - Height of frame area (default = full height)
;                  SiStyle - Required style value for frame elements
;                  SiExStyle - Required extended style value for frame elements
;                  $iInit_Pos - Required initial width/height of left/top frame (default = centre)
; Requirement(s).: v3.3 +
; Return values .: Success:  Returns index number of frame/separator set
;                  Failure:  Returns 0 and sets @error as follows:
;                  1 = Child limit exceeded
;                  2 = GUI creation failed
;                  2 = Separator subclassing failed
; Author ........: Kip
; Modified ......: Melba23
; Remarks .......: - The user must call _GUIFrame_Exit on exit to delete subclassed separator bars to free the
;                  UDF created WndProc and to release the registered Callback.
;                  - Only 1 level of child frames is supported
; Example........: Yes
;=====================================================================================================================
Func _GUIFrame_Create($hWnd, $iSepOrient = 0, $iSepSize = 5, $iX = 0, $iY = 0, $iOrg_Width = 0, $iOrg_Height = 0, $iStyle = 0, $iExStyle = 0, $iInit_Pos = 0)

    Local $iSeparatorX, $iSeparatorY, $hSeparator, $hFirstFrame, $hSecondFrame

    ; Check we are not creating a 3rd level frame
    For $i = $aGF_HandleIndex[0][0] To 1 Step -1
        ; Check previous frames
        If $aGF_HandleIndex[$i][1] = $hWnd Or $aGF_HandleIndex[$i][2] = $hWnd Then
            ; Now see if these frames have a parent
            For $j = 1 To $aGF_HandleIndex[0][0]
                ; If so return
                If $aGF_HandleIndex[$j][1] = $hWnd Or $aGF_HandleIndex[$j][2] = $hWnd Then
                    If $j <> 1 Then Return SetError(1, 0, 0)
                EndIf
            Next
        EndIf
    Next

    ; Set separator size
    Local $iSeparatorSize = 5
    Switch $iSepSize
        Case 3 To 9
            $iSeparatorSize = $iSepSize
    EndSwitch

    ; Set default sizing if no parameters set
    Local $iWidth = $iOrg_Width
    Local $iHeight = $iOrg_Height
    Local $aFullSize = WinGetClientSize($hWnd)
    If Not $iOrg_Width Then $iWidth = $aFullSize[0]
    If Not $iOrg_Height Then $iHeight = $aFullSize[1]

    ; Create parent GUI within client area
    Local $hParent = GUICreate("FrameParent", $iWidth, $iHeight, $iX, $iY, BitOR(0x40000000, $iStyle), $iExStyle, $hWnd) ; $WS_CHILD
    GUISetState(@SW_SHOW, $hParent)

    ; Confirm size of frame parent client area
    Local $aSize = WinGetClientSize($hParent)
    $iWidth = $aSize[0]
    $iHeight = $aSize[1]

    If $iSepOrient = 0 Then

        ; Check initial separator position is required and is within GUI
        If $iInit_Pos > $iWidth Or $iInit_Pos = 0 Then
            $iSeparatorX = Round(($iWidth / 2) - ($iSeparatorSize / 2))
        Else
            $iSeparatorX = $iInit_Pos
        EndIf
        ; Create separator bar and force cursor change over separator
        $hSeparator = GUICreate("", $iSeparatorSize, $iHeight, $iSeparatorX, 0, 0x40000000, -1, $hParent) ;$WS_CHILD
        GUICtrlCreateLabel("", 0, 0, $iSeparatorSize, $iHeight, -1, 0x00000001) ; $WS_EX_DLGMODALFRAME
        GUICtrlSetCursor(-1, 13)
        GUISetState(@SW_SHOW, $hSeparator)
        ; Create the sizable frames
        $hFirstFrame = GUICreate("", $iSeparatorX, $iHeight, 0, 0, 0x40000000, -1, $hParent) ;$WS_CHILD
        GUISetState(@SW_SHOW, $hFirstFrame)
        $hSecondFrame = GUICreate("", $iWidth - ($iSeparatorX + $iSeparatorSize), $iHeight, $iSeparatorX + $iSeparatorSize, 0, 0x40000000, -1, $hParent) ;$WS_CHILD
        GUISetState(@SW_SHOW, $hSecondFrame)

    Else

        If $iInit_Pos > $iHeight Or $iInit_Pos = 0 Then
            $iSeparatorY = Round(($iHeight / 2) - ($iSeparatorSize / 2))
        Else
            $iSeparatorY = $iInit_Pos
        EndIf
        $hSeparator = GUICreate("", $iWidth, $iSeparatorSize, 0, $iSeparatorY, 0x40000000, -1, $hParent) ;$WS_CHILD
        GUICtrlCreateLabel("", 0, 0, $iWidth, $iSeparatorSize, -1, 0x01) ; $WS_EX_DLGMODALFRAME
        GUICtrlSetCursor(-1, 11)
        GUISetState(@SW_SHOW, $hSeparator)
        $hFirstFrame = GUICreate("", $iWidth, $iSeparatorY, 0, 0, 0x40000000, -1, $hParent) ;$WS_CHILD
        GUISetState(@SW_SHOW, $hFirstFrame)
        $hSecondFrame = GUICreate("", $iWidth, $iHeight - ($iSeparatorY + $iSeparatorSize), 0, $iSeparatorY + $iSeparatorSize, 0x40000000, -1, $hParent) ;$WS_CHILD
        GUISetState(@SW_SHOW, $hSecondFrame)

    EndIf

    ; Check for error creating GUIs
    If $hParent = 0 Or $hSeparator = 0 Or $hFirstFrame = 0 Or $hSecondFrame = 0 Then
        ; Delete all GUIs and return error
        GUICreate($hParent)
        GUIDelete($hSeparator)
        GUIDelete($hFirstFrame)
        GUICreate($hSecondFrame)
        Return SetError(2, 0, 0)
    EndIf

    ; Subclass the separator
    If _GUIFrame_SepSubClass($hSeparator) = 0 Then
        ; If Subclassing failed then delete all GUIs and return error
        GUICreate($hParent)
        GUIDelete($hSeparator)
        GUIDelete($hFirstFrame)
        GUICreate($hSecondFrame)
        Return SetError(3, 0, 0)
    EndIf

    ; Create a new line in the arrays
    Local $iIndex = $aGF_HandleIndex[0][0] + 1
    ReDim $aGF_HandleIndex[$iIndex + 1][7]
    ReDim $aGF_SizingIndex[$iIndex + 1][6]
    ReDim $aGF_SettingsIndex[$iIndex + 1][3]

    ; Store this frame set variables/defaults in the new lines
    $aGF_HandleIndex[0][0] = $iIndex
    $aGF_HandleIndex[$iIndex][0] = $hParent
    $aGF_HandleIndex[$iIndex][1] = $hFirstFrame
    $aGF_HandleIndex[$iIndex][2] = $hSecondFrame
    $aGF_HandleIndex[$iIndex][3] = $hSeparator
    $aGF_HandleIndex[$iIndex][5] = 0
    $aGF_HandleIndex[$iIndex][6] = 0
    $aGF_SizingIndex[$iIndex][0] = 0
    $aGF_SizingIndex[$iIndex][1] = 0
    $aGF_SettingsIndex[$iIndex][0] = $iSepOrient
    $aGF_SettingsIndex[$iIndex][1] = 0
    $aGF_SettingsIndex[$iIndex][2] = $iSeparatorSize

    ; Store this frame index in parent line if parent is an existing frame
    For $i = 1 To $aGF_HandleIndex[0][0] - 1
        If $aGF_HandleIndex[$i][1] = $hWnd Then
            If $aGF_HandleIndex[$i][5] = 0 Then
                $aGF_HandleIndex[$i][5] = $iIndex
            Else
                $aGF_HandleIndex[$i][5] &= "|" & $iIndex
            EndIf
            ExitLoop
        EndIf
        If $aGF_HandleIndex[$i][2] = $hWnd Then
            If $aGF_HandleIndex[$i][6] = 0 Then
                $aGF_HandleIndex[$i][6] = $iIndex
            Else
                $aGF_HandleIndex[$i][6] &= "|" & $iIndex
            EndIf
            ExitLoop
        EndIf
    Next

    ; If neither index set, it is a base level GUI so store it
    If $aGF_HandleIndex[$i][5] + $aGF_HandleIndex[$i][6] = 0 Then $aGF_HandleIndex[$iIndex][4] = $hWnd

    ; Store coordinate and size fractions
    If $iX Then
        $aGF_SizingIndex[$iIndex][2] = $iX / $aFullSize[0]
    Else
        $aGF_SizingIndex[$iIndex][2] = 0
    EndIf
    If $iY Then
        $aGF_SizingIndex[$iIndex][3] = $iY / $aFullSize[1]
    Else
        $aGF_SizingIndex[$iIndex][3] = 0
    EndIf
    If $iOrg_Width Then
        $aGF_SizingIndex[$iIndex][4] = $iOrg_Width / $aFullSize[0]
    Else
        $aGF_SizingIndex[$iIndex][4] = 1
    EndIf
    If $iOrg_Height Then
        $aGF_SizingIndex[$iIndex][5] = $iOrg_Height / $aFullSize[1]
    Else
        $aGF_SizingIndex[$iIndex][5] = 1
    EndIf

    ; Switch back to main GUI
    GUISwitch($hWnd)

    ; Return the index for this frame
    Return $iIndex

EndFunc   ;==>_GUIFrame_Create

; #FUNCTION# =========================================================================================================
; Name...........: _GUIFrame_SetMin
; Description ...: Sets minimum sizes for frames
; Syntax.........: _GUIFrame_SetMin($iFrame, $iFirstMin = 0, $iSecondMin = 0)
; Parameters ....: $iFrame - Index of frame set as returned by _GUIFrame_Create
;                  $iFirstMin - Min size of first (left/top) frame - max half size
;                  $iSecondMin - Min Size of second (right/bottom) frame - max half size
; Requirement(s).: v3.3 +
; Return values .: None
; Author ........: Melba23 based on some original code by Kip
; Modified ......:
; Remarks .......: If the frame is resized, these minima are adjusted accordingly
; Example........: Yes
;=====================================================================================================================
Func _GUIFrame_SetMin($iFrame, $iFirstMin = 0, $iSecondMin = 0)

    ; Check for valid frame index
    If $iFrame < 1 Or $iFrame > $aGF_HandleIndex[0][0] Then Return 0
    ; Get size of parent
    Local $aSize = WinGetClientSize($aGF_HandleIndex[$iFrame][0])
    ; Now check orientation and determine
    Local $iMax, $iFullSize
    If $aGF_SettingsIndex[$iFrame][0] = 0 Then
        $iMax = Floor(($aSize[0] / 2) - $aGF_SettingsIndex[$iFrame][2])
        $iFullSize = $aSize[0]
    Else
        $iMax = Floor(($aSize[1] / 2) - $aGF_SettingsIndex[$iFrame][2])
        $iFullSize = $aSize[1]
    EndIf
    ; Set minimums
    If $iFirstMin > $iMax Then
        $aGF_SizingIndex[$iFrame][0] = $iMax / $iFullSize
    Else
        $aGF_SizingIndex[$iFrame][0] = $iFirstMin / $iFullSize
    EndIf
    If $iSecondMin > $iMax Then
        $aGF_SizingIndex[$iFrame][1] = $iMax / $iFullSize
    Else
        $aGF_SizingIndex[$iFrame][1] = $iSecondMin / $iFullSize
    EndIf

EndFunc   ;==>_GUIFrame_SetMin

; #FUNCTION# =========================================================================================================
; Name...........:  _GUIFrame_ResizeSet
; Description ...: Sets resizing flag for frames
; Syntax.........:  _GUIFrame_ResizeSet($iFrame = 0)
; Parameters ....: $iFrame - Index of frame set as returned by _GUIFrame_Create
;                  (Default - 0 = all existing frames)
; Requirement(s).: v3.3 +
; Return values .: Success: 2 - All existing frame flags set
;                           1 - Specified flag set
;                  Failure: 0 with @error set to 1 - Invalid frame specified
; Author ........: Melba23
; Modified ......:
; Remarks .......:
; Example........: Yes
;=====================================================================================================================
Func _GUIFrame_ResizeSet($iFrame = 0)

    Switch $iFrame
        Case 0 ; Set all frames
            For $i = 1 To $aGF_HandleIndex[0][0]
                $aGF_SettingsIndex[$i][1] = 1
            Next
            Return 2
        Case 1 To $aGF_HandleIndex[0][0] ; Only valid frames accepted
            $aGF_SettingsIndex[$iFrame][1] = 1
            Return 1
        Case Else ; Error
            Return SetError(1, 0, 0)
    EndSwitch

EndFunc   ;==>_GUIFrame_ResizeSet

; #FUNCTION# =========================================================================================================
; Name...........: _GUIFrame_ResizeReg
; Description ...: Registers WM_MOVE mesasge for resizing
; Syntax.........:  _GUIFrame_ResizeReg()
; Parameters ....: None
; Requirement(s).: v3.3 +
; Return values .: Success: 1 - Message handler registered
;                  Failure: 0 with @error set to 1
; Author ........: Melba23
; Modified ......:
; Remarks .......:
; Example........: Yes
;=====================================================================================================================
Func _GUIFrame_ResizeReg()

    ; Register the WM_MOVE message
    If $aGF_HandleIndex[0][1] = 0 Then
        Local $iRet = GUIRegisterMsg(0x05, "_GUIFrame_SIZE_Handler") ; $WM_SIZE
        If $iRet Then
            $aGF_HandleIndex[0][1] = 1
            Return 1
        EndIf
    EndIf
    Return SetError(1, 0, 0)

EndFunc   ;==>_GUIFrame_ResizeReg

; #FUNCTION# =========================================================================================================
; Name...........: _GUIFrame_SIZE_Handler
; Description ...: Used to resize frames when a top-level GUI is resized
; Syntax.........: _GUIFrame_SIZE_Handler($hWnd, $iMsg, $wParam, $lParam)
; Parameters ....: None
; Requirement(s).: v3.3 +
; Return values .: None
; Author ........: Melba23
; Modified ......:
; Remarks .......: If the script already has a WM_SIZE handler, then just call this function from within it
;                  and do NOT use the _GUIFrame_ResizeReg function
; Example........: Yes
;=====================================================================================================================
Func _GUIFrame_SIZE_Handler($hWnd, $iMsg, $wParam, $lParam)

    #forceref $iMsg, $wParam, $lParam

    Local $iIndex

    ; Get index of base frame set
    For $iIndex = 1 To $aGF_HandleIndex[0][0]
        If $aGF_HandleIndex[$iIndex][4] = $hWnd Then ExitLoop
    Next

    ; If handle not found
    If $iIndex > $aGF_HandleIndex[0][0] Then Return "GUI_RUNDEFMSG"

    ; Get new GUI size
    Local $aSize = WinGetClientSize($hWnd)

    ; Resize frame
    _GUIFrame_Move($iIndex, $aSize[0] * $aGF_SizingIndex[$iIndex][2], $aSize[1] * $aGF_SizingIndex[$iIndex][3], $aSize[0] * $aGF_SizingIndex[$iIndex][4], $aSize[1] * $aGF_SizingIndex[$iIndex][5])

    ; Adjust any resizeable internal framess
    _GUIFrame_AdjIntFrames($iIndex)

    Return "GUI_RUNDEFMSG"

EndFunc   ;==>_GUIFrame_SIZE_Handler

; #FUNCTION# =========================================================================================================
; Name...........: _GUIFrame_GetHandle
; Description ...: Returns the handle of a frame element (required for further splitting)
; Syntax.........: _GUIFrame_GetHandle($iFrame, $iElement)
; Parameters ....: $iFrame - Index of frame set as returned by _GUIFrame_Create
;                  $iElement - 1 = first (left/top) frame, 2 = second (right/bottom) frame
; Requirement(s).: v3.3 +
; Return values .: Success: Handle of frame
;                  Failure: 0 with @error set as follows
;                           1 - Invalid frame specified
;                           2 - Invalid element specified
; Author ........: Kip
; Modified ......: Melba23
; Remarks .......: _GUIFrame_Create requires a GUI handle as a parameter
; Example........: Yes
;=====================================================================================================================
Func _GUIFrame_GetHandle($iFrame, $iElement)

    ; Check valid frame index and element
    Switch $iFrame
        Case 1 To $aGF_HandleIndex[0][0]
            Switch $iElement
                Case 1, 2
                    ; Return handle
                    Return $aGF_HandleIndex[$iFrame][$iElement]
            EndSwitch
            Return SetError(2, 0, 0)
    EndSwitch
    Return SetError(1, 0, 0)

EndFunc   ;==>_GUIFrame_GetHandle

; #FUNCTION# =========================================================================================================
; Name...........: _GUIFrame_Switch
; Description ...: Sets a frame element as current GUI
; Syntax.........: _GUIFrame_Switch($iFrame, $iElement)
; Parameters ....: $iFrame - Index of frams set as returned by _GUIFrame_Create
;                  $iElement - 1 = first (left/top) frame, 2 = second (right/bottom) frame
; Requirement(s).: v3.3 +
; Return values .: None
; Author ........: Kip
; Modified ......: Melba23
; Remarks .......: Subsequent controls are created in the specified frame element
; Example........: Yes
;=====================================================================================================================
Func _GUIFrame_Switch($iFrame, $iElement)

    ; Check valid frame index and element
    Switch $iFrame
        Case 1 To $aGF_HandleIndex[0][0]
            Switch $iElement
                Case 1, 2
                    ; Switch to specified element
                    Return GUISwitch($aGF_HandleIndex[$iFrame][$iElement])
            EndSwitch
            Return SetError(2, 0, 0)
    EndSwitch
    Return SetError(1, 0, 0)

EndFunc   ;==>_GUIFrame_Switch

; #FUNCTION# =========================================================================================================
; Name...........: _GUIFrame_Exit()
; Description ...: Deletes all subclassed separator bars to free UDF WndProc and frees registered callback handle
; Syntax.........:_GUIFrame_Exit()
; Parameters ....: None
; Requirement(s).: v3.3 +
; Return values .: None
; Author ........: Kip
; Modified ......: Melba23
; Remarks .......: The user must call _GUIFrame_Exit on exit to delete all subclassed separator bars and so free the
;                  UDF created WndProc.
; Example........: Yes
;=====================================================================================================================
Func _GUIFrame_Exit()

    ; Delete all subclassed separator bars
    For $i = $aGF_HandleIndex[0][0] To 1 Step -1
        GUIDelete($aGF_HandleIndex[$i][3])
    Next
    ; Free registered Callback handle
    DllCallbackFree($hGF_RegCallBack)

EndFunc   ;==>_GUIFrame_Exit

; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _GUIFrame_SepSubClass
; Description ...: Sets new WndProc for frame separator bar
; Author ........: Kip
; Modified.......: Melba23
; Remarks .......: This function is used internally by _GUIFrame_Create
; ===============================================================================================================================
Func _GUIFrame_SepSubClass($hWnd)

    ; Check separator has not already been used
    For $i = 1 To $aGF_SepProcIndex[0][0]
        If $aGF_SepProcIndex[$i][0] = $hWnd Then Return 0
    Next

    ; Store current WinProc handle in new array line
    Local $iIndex = $aGF_SepProcIndex[0][0] + 1
    ReDim $aGF_SepProcIndex[$iIndex + 1][2]
    $aGF_SepProcIndex[0][0] = $iIndex
    $aGF_SepProcIndex[$iIndex][0] = $hWnd
    $aGF_SepProcIndex[$iIndex][1] = _WinAPI_SetWindowLong($hWnd, -4, $aGF_SepProcIndex[0][1]) ; $GWL_WNDPROC

    ; Check for subclassing error
    If @error Or $aGF_SepProcIndex[$iIndex][1] = 0 Then Return 0
    ; Return success
    Return 1

EndFunc   ;==>_GUIFrame_SepSubClass

; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _GUIFrame_SepWndProc
; Description ...: New WndProc for frame separator bar
; Author ........: Kip
; Modified.......: Melba23
; Remarks .......: This function is used internally by _GUIFrame_SepSubClass
; ===============================================================================================================================
Func _GUIFrame_SepWndProc($hWnd, $iMsg, $wParam, $lParam)

    Local $iSubtract

    If $iMsg = 0x0111 Then ; WM_COMMAND

        ; Check if hWnd is a Separator bar
        For $iIndex = 1 To $aGF_HandleIndex[0][0]
            If $aGF_HandleIndex[$iIndex][3] = $hWnd Then ExitLoop
        Next
        ; If not then pass message on to org WndProc
        If $iIndex > $aGF_HandleIndex[0][0] Then Return _GUIFrame_SepPassMsg($hWnd, $iMsg, $wParam, $lParam)

        ; Extract values from array
        Local $hParent = $aGF_HandleIndex[$iIndex][0]
        Local $hFirstFrame = $aGF_HandleIndex[$iIndex][1]
        Local $hSecondFrame = $aGF_HandleIndex[$iIndex][2]
        Local $hSeparator = $aGF_HandleIndex[$iIndex][3]
        Local $iFirstMin = $aGF_SizingIndex[$iIndex][0]
        Local $iSecondMin = $aGF_SizingIndex[$iIndex][1]
        Local $iSeparatorSize = $aGF_SettingsIndex[$iIndex][2]

        ; Get client size of the parent
        Local $aClientSize = WinGetClientSize($hParent)
        Local $iWidth = $aClientSize[0]
        Local $iHeight = $aClientSize[1]

        ; Get cursor info for the Separator
        Local $aCInfo = GUIGetCursorInfo($hSeparator)

        ; Depending on separator orientation
        If $aGF_SettingsIndex[$iIndex][0] = 0 Then

            ; Get Separator X-coord
            $iSubtract = $aCInfo[0]

            Do

                ; Get parent X-coord
                $aCInfo = GUIGetCursorInfo($hParent)
                Local $iCursorX = $aCInfo[0]

                ; Determine width of first frame
                Local $iFirstWidth = $iCursorX - $iSubtract
                ; And ensure it is at least minimum
                If $iFirstWidth < $iWidth * $iFirstMin Then $iFirstWidth = $iWidth * $iFirstMin
                If $iWidth - ($iFirstWidth + $iSeparatorSize) < $iWidth * $iSecondMin Then $iFirstWidth = $iWidth - ($iWidth * $iSecondMin) - $iSeparatorSize

                ; Move the GUIs to the correct places
                WinMove($hFirstFrame, "", 0, 0, $iFirstWidth, $iHeight)
                WinMove($hSecondFrame, "", $iFirstWidth + $iSeparatorSize, 0, $iWidth - ($iFirstWidth + $iSeparatorSize), $iHeight)
                WinMove($hSeparator, "", $iFirstWidth, 0, $iSeparatorSize, $iHeight)

                ; Adjust any resizeable internal frames
                _GUIFrame_AdjIntFrames($iIndex)

                ; Do until the mouse button is released
            Until Not _WinAPI_GetAsyncKeyState(0x01)

        ElseIf $aGF_SettingsIndex[$iIndex][0] = 1 Then

            $iSubtract = $aCInfo[1]
            Do
                $aCInfo = GUIGetCursorInfo($hParent)
                Local $iCursorY = $aCInfo[1]
                Local $iFirstHeight = $iCursorY - $iSubtract
                If $iFirstHeight < $iHeight * $iFirstMin Then $iFirstHeight = $iHeight * $iFirstMin
                If $iHeight - ($iFirstHeight + $iSeparatorSize) < $iHeight * $iSecondMin Then $iFirstHeight = $iHeight - ($iHeight * $iSecondMin) - $iSeparatorSize
                WinMove($hFirstFrame, "", 0, 0, $iWidth, $iFirstHeight)
                WinMove($hSecondFrame, "", 0, $iFirstHeight + $iSeparatorSize, $iWidth, $iHeight - ($iFirstHeight + $iSeparatorSize))
                WinMove($hSeparator, "", 0, $iFirstHeight, $iWidth, $iSeparatorSize)
                _GUIFrame_AdjIntFrames($iIndex)
            Until Not _WinAPI_GetAsyncKeyState(0x01)

        EndIf

    EndIf

    ; Pass the message on to org WndProc
    Return _GUIFrame_SepPassMsg($hWnd, $iMsg, $wParam, $lParam)

EndFunc   ;==>_GUIFrame_SepWndProc

; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _GUIFrame_SepPassMsg
; Description ...: Passes Msg to frame parent WndProc for action
; Author ........: Kip
; Modified.......: Melba23
; Remarks .......: This function is used internally by _GUIFrame_SepWndProc
; ===============================================================================================================================
Func _GUIFrame_SepPassMsg($hWnd, $iMsg, $wParam, $lParam)

    For $i = 1 To $aGF_SepProcIndex[0][0]
        If $aGF_SepProcIndex[$i][0] = $hWnd Then Return _WinAPI_CallWindowProc($aGF_SepProcIndex[$i][1], $hWnd, $iMsg, $wParam, $lParam)
    Next

EndFunc   ;==>_GUIFrame_SepPassMsg

; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _GUIFrame_Move
; Description ...: Moves and resizes frame elements and separator bars
; Author ........: Kip
; Modified.......: Melba23
; Remarks .......: This function is used internally by _GUIFrame_SepWndProc and _GUIFrame_SIZE_Handler
; ===============================================================================================================================
Func _GUIFrame_Move($iFrame, $iX, $iY, $iWidth = 0, $iHeight = 0)

    ; Check valid frame index
    If $iFrame < 1 Or $iFrame > $aGF_HandleIndex[0][0] Then Return 0

    Local $iSeparatorSize = $aGF_SettingsIndex[$iFrame][2]
    Local $iTotal

    ; Set size if not specified
    If Not $iWidth Then $iWidth = _WinAPI_GetWindowWidth($aGF_HandleIndex[$iFrame][0])
    If Not $iHeight Then $iHeight = _WinAPI_GetWindowHeight($aGF_HandleIndex[$iFrame][0])

    ; Move parent
    WinMove($aGF_HandleIndex[$iFrame][0], "", $iX, $iY, $iWidth, $iHeight)

    ; Get size of first frame depending on orientation
    Local $aWinPos = WinGetClientSize($aGF_HandleIndex[$iFrame][1])
    Local $iSize = $aWinPos[0]
    If $aGF_SettingsIndex[$iFrame][0] = 1 Then $iSize = $aWinPos[1]

    ; Set frame min percentages
    Local $iFirstMin = $aGF_SizingIndex[$iFrame][0]
    Local $iSecondMin = $aGF_SizingIndex[$iFrame][1]

    ; Depending on separator orientation
    If $aGF_SettingsIndex[$iFrame][0] = 0 Then

        ; Move frames and separator as required
        $iTotal = $iWidth
        If $iSize < $iWidth * $iFirstMin Then $iSize = $iWidth * $iFirstMin
        If $iTotal - $iSize - $iSeparatorSize < $iWidth * $iSecondMin Then $iSize = $iTotal - ($iWidth * $iSecondMin) - $iSeparatorSize
        WinMove($aGF_HandleIndex[$iFrame][1], "", 0, 0, $iSize, $iHeight)
        WinMove($aGF_HandleIndex[$iFrame][2], "", $iSize + $iSeparatorSize, 0, $iTotal - $iSize - $iSeparatorSize, $iHeight)
        WinMove($aGF_HandleIndex[$iFrame][3], "", $iSize, 0, $iSeparatorSize, $iHeight)

    ElseIf $aGF_SettingsIndex[$iFrame][0] = 1 Then

        $iTotal = $iHeight
        If $iSize < $iHeight * $iFirstMin Then $iSize = $iHeight * $iFirstMin
        If $iTotal - $iSize - $iSeparatorSize < $iHeight * $iSecondMin Then $iSize = $iTotal - ($iHeight * $iSecondMin) - $iSeparatorSize
        WinMove($aGF_HandleIndex[$iFrame][1], "", 0, 0, $iWidth, $iSize)
        WinMove($aGF_HandleIndex[$iFrame][2], "", 0, $iSize + $iSeparatorSize, $iWidth, $iTotal - $iSize - $iSeparatorSize)
        WinMove($aGF_HandleIndex[$iFrame][3], "", 0, $iSize, $iWidth, $iSeparatorSize)

    EndIf

EndFunc   ;==>_GUIFrame_Move

; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _GUIFrame_AdjIntFrames
; Description ...: Moves and resizes internal frame elements when parent frame is resized
; Author ........: Melba23
; Modified.......:
; Remarks .......: This function is called by _GUIFrame_SepWndProc and _GUIFrame_SIZE_Handler
; ===============================================================================================================================
Func _GUIFrame_AdjIntFrames($iIndex)

    Local $aInternal, $iIntIndex, $aPos

    ; Array elements are adjacent for ease of coding
    For $i = 0 To 1

        ; Adjust internal frames of first/second frame if any exist
        If $aGF_HandleIndex[$iIndex][5 + $i] <> 0 Then
            ; StringSplit the element content on "|"
            $aInternal = StringSplit($aGF_HandleIndex[$iIndex][5 + $i], "|")
            ; Then loop though the Number(values) found
            For $j = 1 To $aInternal[0]
                $iIntIndex = Number($aInternal[$j])
                ; Check if internal frame is resizable
                If $aGF_SettingsIndex[$iIntIndex][1] = 1 Then
                    ; Get size of first/second frame
                    $aPos = WinGetPos($aGF_HandleIndex[$iIndex][1 + $i])
                    ; Adjust sizes of the separator and frames
                    _GUIFrame_Move($iIntIndex, $aPos[2] * $aGF_SizingIndex[$iIntIndex][2], $aPos[3] * $aGF_SizingIndex[$iIntIndex][3], $aPos[2] * $aGF_SizingIndex[$iIntIndex][4], $aPos[3] * $aGF_SizingIndex[$iIntIndex][5])
                EndIf
            Next
        EndIf
    Next

EndFunc   ;==>_GUIFrame_AdjIntFrames

And now the example:

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

#include "GUIFrame.au3"

; Create the main GUI
$hGUI_1 = GUICreate("GUI Frames", 600, 500, 100, 100, $WS_SIZEBOX)
GUISetState(@SW_SHOW, $hGUI_1)

; Create a full size vertically-divided frame within the main GUI
$iFrame_A = _GUIFrame_Create($hGUI_1, 0, 5, 0, 0, 0, 0, 0, 0, 100) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; Register the WM_MOVE message as we do not register it elsewhere in the script
_GUIFrame_ResizeReg()
; Set all existing frames to resizeable
_GUIFrame_ResizeSet(0)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ; Delete all subclassed separators and free Callback
            _GUIFrame_Exit()
            Exit
    EndSwitch
WEnd

Sorry about the rather long syntax for the function call (<<<<<<<<<<<<<<<<<) needed to include the new parameter - but anything else would be script breaking. ;)

I hope it does what you want. I am afraid the rewrite to deal with the final question would require a great deal more work and will have to wait for another day. :shocked:

M23

Edit: Your English is fine, by the way. :) Purely out of interest, what is your mother tongue?

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

E1M1,

you probably never heard that languge

You would be surprised! ;) I had a lot to do with the 3 Baltic states a few years ago and met plenty of Estonians - although I cannot speak a single word I certainly heard a lot. :)

Glad you like the new version of the UDF - I will test it thoroughly over the next few days and then probably post it as a new release. ;)

Head ööd,

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

E1M1,

The Queen's English for me.

As to what I was doing in the Baltic states..... ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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