johnmcloud Posted October 27, 2012 Share Posted October 27, 2012 (edited) Hi guys,I'ts hard to explain for me, so i'll post directly an example.I want to definite the max area for the position of a gui, so i don't want to make something like this image:But an area ( in red ) like this:The Parent-Child GUI was only an example, anyway i'll post it:#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinApi.au3> $hGUI_Parent = GUICreate("Parent", 500, 500) GUISetState() $hGUI_Child = GUICreate("Child", 200, 200, 10, 20, BitOR($WS_MAXIMIZEBOX, $GUI_SS_DEFAULT_GUI)) GUISetState() _WinAPI_SetParent($hGUI_Child, $hGUI_Parent While 1 $Msg = GUIGetMsg(1) Switch $Msg[0] Case $GUI_EVENT_CLOSE If $Msg[1] = $hGUI_Child Then GUIDelete($hGUI_Child) Else Exit EndIf EndSwitch WEndI have think something with WinGetPos, maybe if the gui2 position is more then gui1 size then move inside again, but i don't know if is the correct approach.Thanks for any help/suggestion Edited October 27, 2012 by johnmcloud Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 27, 2012 Moderators Share Posted October 27, 2012 johnmcloud, I cannot do it with an API child, but I can with a MIDI child: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> $hGUI_Parent = GUICreate("Parent", 500, 500) GUISetState() $hGUI_Child_API = GUICreate("API Child", 200, 200, 100, 100, BitOR($WS_MAXIMIZEBOX, $GUI_SS_DEFAULT_GUI)) _WinAPI_SetParent($hGUI_Child_API, $hGUI_Parent) GUISetState() $hGUI_Child_MIDI = GUICreate("MIDI Child", 200, 200, 200, 200, BitOR($WS_MAXIMIZEBOX, $GUI_SS_DEFAULT_GUI), $WS_EX_MDICHILD, $hGUI_Parent) GUISetState() GUIRegisterMsg($WM_WINDOWPOSCHANGING, "_WM_WINDOWPOSCHANGING") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _WM_WINDOWPOSCHANGING($hWnd, $Msg, $wParam, $lParam) Switch $hWnd Case $hGUI_Child_API, $hGUI_Child_MIDI ; Get position of parent Local $aMain_Pos = WinGetPos($hGUI_Parent) If Not IsArray($aMain_Pos) Then Return ; Get position of child Local $stWinPos = DllStructCreate("uint;uint;int;int;int;int;uint", $lParam) Local $iLeft = DllStructGetData($stWinPos, 3) Local $iTop = DllStructGetData($stWinPos, 4) Local $iWidth = DllStructGetData($stWinPos, 5) Local $iHeight = DllStructGetData($stWinPos, 6) ; Set drag limits Local $iX_Min = $aMain_Pos[0] Local $iY_Min = $aMain_Pos[1] + 24 Local $iX_Max = $aMain_Pos[0] + $aMain_Pos[2] - $iWidth Local $iY_Max = $aMain_Pos[1] + $aMain_Pos[3] - $iHeight ; And reset them if passed If $iLeft < $iX_Min Then DllStructSetData($stWinPos, 3, $iX_Min) If $iLeft > $iX_Max Then DllStructSetData($stWinPos, 3, $iX_Max) If $iTop < $iY_Min Then DllStructSetData($stWinPos, 4, $iY_Min) If $iTop > $iY_Max Then DllStructSetData($stWinPos, 4, $iY_Max) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_WINDOWPOSCHANGING Any use? M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
johnmcloud Posted October 27, 2012 Author Share Posted October 27, 2012 (edited) Hi melba, I can't use MIDI child, and API don't work very well This is what i have do for now ( so you can't say i don't work lol ) expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinApi.au3> $hGUI_Parent = GUICreate("Parent", 500, 500) GUISetState() $hGUI_Child = GUICreate("Child", 200, 300, 10, 20, BitOR($WS_MAXIMIZEBOX, $GUI_SS_DEFAULT_GUI)) $hButton = GUICtrlCreateButton("Test", 10, 10, 50, 50) GUISetState() _WinAPI_SetParent($hGUI_Child, $hGUI_Parent) While 1 $Msg = GUIGetMsg(1) Switch $Msg[0] Case $GUI_EVENT_CLOSE If $Msg[1] = $hGUI_Child Then GUIDelete($hGUI_Child) Else Exit EndIf EndSwitch Test() WEnd Func Test() Local $size_parent = WinGetPos($hGUI_Parent) Local $size_child = WinGetPos($hGUI_Child) If IsArray($size_parent) Then If IsArray($size_child) Then $x_parent = $size_parent[0] $y_parent = $size_parent[1] $w_parent = $size_parent[2] $h_parent = $size_parent[3] $x_child = $size_child[0] $y_child = $size_child[1] $w_child = $size_child[2] $h_child = $size_child[3] If $x_child <= $x_parent Then WinMove($hGUI_Child, "", -1, -1) EndIf If $x_child >= $w_parent - $w_child + $x_parent Then WinMove($hGUI_Child, "", $w_parent - $w_child - $w_child / 36, -1) EndIf If $y_child >= $h_parent - $h_child + $y_parent Then WinMove($hGUI_Child, "", -1, $h_parent - $h_child - $y_child / 12) EndIf If $y_child <= $y_parent * 2 Then WinMove($hGUI_Child, "", -1, $y_parent / 12) EndIf EndIf EndIf EndFunc ;==>Test Maybe we can merge both system, and add a limit insted of WinMove EDIT: Change this part of code: Local $iX_Min = $aMain_Pos[0] - $aMain_Pos[0] Local $iY_Min = $aMain_Pos[1] - $aMain_Pos[1] Local $iX_Max = $aMain_Pos[0] + $aMain_Pos[2] - $aMain_Pos[0] - $iWidth Local $iY_Max = $aMain_Pos[1] + $aMain_Pos[3] - $aMain_Pos[1] - $iHeight And you have the correct limit for API GUI The left and top are perfect, but right and down not, some mm Edited October 27, 2012 by johnmcloud Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 27, 2012 Moderators Share Posted October 27, 2012 johnmcloud, I have fixed the API problem: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> $hGUI_Parent = GUICreate("Parent", 500, 500) GUISetState() $hGUI_Child_API = GUICreate("API Child", 200, 200, 100, 100, BitOR($WS_MAXIMIZEBOX, $GUI_SS_DEFAULT_GUI)) _WinAPI_SetParent($hGUI_Child_API, $hGUI_Parent) GUISetState() $hGUI_Child_MIDI = GUICreate("MIDI Child", 200, 200, 200, 200, BitOR($WS_MAXIMIZEBOX, $GUI_SS_DEFAULT_GUI), $WS_EX_MDICHILD, $hGUI_Parent) GUISetState() GUIRegisterMsg($WM_WINDOWPOSCHANGING, "_WM_WINDOWPOSCHANGING") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _WM_WINDOWPOSCHANGING($hWnd, $Msg, $wParam, $lParam) ; Get position of parent Local $aMain_Pos = WinGetPos($hGUI_Parent) If Not IsArray($aMain_Pos) Then Return Switch $hWnd Case $hGUI_Child_MIDI ; Get position of child Local $stWinPos = DllStructCreate("uint;uint;int;int;int;int;uint", $lParam) Local $iLeft = DllStructGetData($stWinPos, 3) Local $iTop = DllStructGetData($stWinPos, 4) Local $iWidth = DllStructGetData($stWinPos, 5) Local $iHeight = DllStructGetData($stWinPos, 6) ; Set drag limits Local $iX_Min = $aMain_Pos[0] Local $iY_Min = $aMain_Pos[1] + 24 Local $iX_Max = $aMain_Pos[0] + $aMain_Pos[2] - $iWidth Local $iY_Max = $aMain_Pos[1] + $aMain_Pos[3] - $iHeight ; And reset them if passed If $iLeft < $iX_Min Then DllStructSetData($stWinPos, 3, $iX_Min) If $iLeft > $iX_Max Then DllStructSetData($stWinPos, 3, $iX_Max) If $iTop < $iY_Min Then DllStructSetData($stWinPos, 4, $iY_Min) If $iTop > $iY_Max Then DllStructSetData($stWinPos, 4, $iY_Max) Case $hGUI_Child_API ; Get position of child Local $stWinPos = DllStructCreate("uint;uint;int;int;int;int;uint", $lParam) Local $iLeft = DllStructGetData($stWinPos, 3) Local $iTop = DllStructGetData($stWinPos, 4) Local $iWidth = DllStructGetData($stWinPos, 5) Local $iHeight = DllStructGetData($stWinPos, 6) ; Set drag limits Local $iX_Min = 0 Local $iY_Min = 0 Local $iX_Max = $aMain_Pos[2] - $iWidth Local $iY_Max = $aMain_Pos[3] - $iHeight ; And reset them if passed If $iLeft < $iX_Min Then DllStructSetData($stWinPos, 3, $iX_Min) If $iLeft > $iX_Max Then DllStructSetData($stWinPos, 3, $iX_Max) If $iTop < $iY_Min Then DllStructSetData($stWinPos, 4, $iY_Min) If $iTop > $iY_Max Then DllStructSetData($stWinPos, 4, $iY_Max) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_WINDOWPOSCHANGING I was using the wrong coordinates. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
johnmcloud Posted October 27, 2012 Author Share Posted October 27, 2012 Cool, i have see you have make wrong coordinate for the API, check the post #3 Don't worry, even Homer sometimes nods Thanks for your help. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 27, 2012 Moderators Share Posted October 27, 2012 johnmcloud, Sorry, I missed your post. Well done for finding the solution yourself! And if you think I do not make many errors - check the number of edited posts I have! M23 P.S. Have you worked out how to concatenate more than 2 arrays yet? 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
johnmcloud Posted October 28, 2012 Author Share Posted October 28, 2012 P.S. Have you worked out how to concatenate more than 2 arrays yet? Yes, was a stupid question, just concatenate two and concatenate again for the third, forget to say lol Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 28, 2012 Moderators Share Posted October 28, 2012 johnmcloud, I knew you would get it. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now