Jtssi Posted October 3, 2023 Share Posted October 3, 2023 (edited) Hello, I have a big issue with position and dimensions, whether it's the MAIN window or the TOOL sub-window. When I exit the application, `wingetpos` does not correctly save the dimensions: After the 1st save: [main] pos_x=200 pos_y=200 size_x=1214 size_y=814 [tool] pos_x=28 pos_y=51 size_x=206 size_y=129 After the 2nd save: [main] pos_x=200 pos_y=200 size_x=1228 size_y=828 [tool] pos_x=36 pos_y=82 size_x=212 size_y=158 How can I fix this? Thank you for your help. Edited October 3, 2023 by Jtssi Link to comment Share on other sites More sharing options...
Jtssi Posted October 3, 2023 Author Share Posted October 3, 2023 (edited) expandcollapse popupOpt("GUIOnEventMode",1) Opt("WinSearchChildren",1) $guiname = "MAIN" $gui = GUICreate($guiname,IniRead(@ScriptDir & "\test.ini","main","size_x","1200"),IniRead(@ScriptDir & "\test.ini","main","size_y","800"),IniRead(@ScriptDir & "\test.ini","main","pos_x","200"),IniRead(@ScriptDir & "\test.ini","main","pos_y","200"),BitOR(0x00010000,0x00020000,0x00040000)) GUISetOnEvent(-3,"_Exit_",$gui) GUICtrlCreateLabel("",-100,-100,0,0) GUISetState() $guiname_tool = "TOOL" $gui_tool = GUICreate($guiname_tool,IniRead(@ScriptDir & "\test.ini","tool","size_x","200"),IniRead(@ScriptDir & "\test.ini","tool","size_y","100"),IniRead(@ScriptDir & "\test.ini","tool","pos_x","20"),IniRead(@ScriptDir & "\test.ini","tool","pos_y","20"),0x00C00000,-1,$gui) DllCall("user32.dll","int","SetParent","hwnd",$gui_tool,"hwnd",$gui) GUICtrlCreateLabel("",-100,-100,0,0) GUISetState(@SW_SHOW,$gui_tool) While 1 Sleep(100) WEnd Func _Exit_() $pos_main = WinGetPos($guiname) IniWrite(@ScriptDir & "\test.ini","main","pos_x",$pos_main[0]) IniWrite(@ScriptDir & "\test.ini","main","pos_y",$pos_main[1]) IniWrite(@ScriptDir & "\test.ini","main","size_x",$pos_main[2]) IniWrite(@ScriptDir & "\test.ini","main","size_y",$pos_main[3]) $pos_tool = _Win_GetChildPos($guiname,$guiname_tool) IniWrite(@ScriptDir & "\test.ini","tool","pos_x",$pos_tool[0] - $pos_main[0]) IniWrite(@ScriptDir & "\test.ini","tool","pos_y",$pos_tool[1] - $pos_main[1]) IniWrite(@ScriptDir & "\test.ini","tool","size_x",$pos_tool[2]) IniWrite(@ScriptDir & "\test.ini","tool","size_y",$pos_tool[3]) Exit EndFunc Func _Win_GetChildPos($h_parent, $h_child) Local $h_wnd = ControlGetHandle($h_parent, "", $h_child) Return WinGetPos($h_wnd) EndFunc Edited October 3, 2023 by Jtssi the code Link to comment Share on other sites More sharing options...
Andreik Posted October 3, 2023 Share Posted October 3, 2023 You need to take in consideration that window has a title bar and borders. You really need to know what exactly do you want to save, the size/position of the entire window or the size/position of window client area. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Jtssi Posted October 3, 2023 Author Share Posted October 3, 2023 Hello, in fact I'd like to save everything (position and size of MAIN and TOOL windows), to restore them as they are when I run the script again. 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