#NoTrayIcon #include #include #include #include #include #cs 2016/08/22 : From Grosminet (A.A.) The purpose of this script is to verify the position settings for different control when the Application's window size is updated by the user. See below for arrays containing --> $aGUI_LineCTRL_? S - Style values to apply to the control eS - Extended Style values ID - control ID returned using the "GUICtrlCreatexxx" control builder T - Type of the control W - Percentage of the client area width to be applied to the control (any % value) H - Percentage of the client area height to be applied to the control (Sum of % should be less or equal to 100% !) ANOMALIES : 2 traces are done using the Console: From the "_UpdateGUI()" function, which use the "GUICtrlSetPos" command to set the new current control position after Application's window size update done by the user From the "_DumpCurrentGUI()" function, which use the "ControlGetPos" command to dump the current control position ==> Comparing the "WIDTH" values: no problem -> same values found ==> Comparing the "HEIGHT" values: !!! ANOMALIES !!! -> not the same values, and not the same diferences for the 2 controls and during different Application's window size updates. #ce ; ************************************************************ Global $GUILinesNB = 2 ; ex. 2 'lines' of control (2 stages !) Global $GUICtrlNB = 2 ; total nb of controls Global $aGUI_LineCTRL_S[$GUILinesNB][2] = [[1, $LBS_SORT], [1, $LBS_SORT]] ; Initial control's Style inside line Global $aGUI_LineCTRL_eS[$GUILinesNB][2] = [[1, -1], [1, -1]] ; Initial control's exStyle inside line Global $aGUI_LineCTRL_ID[$GUILinesNB][2] ; Control's ID Global $aGUI_LineCTRL_T[$GUILinesNB][2] = [[1, "List"], [1, "List"]] ; Control's Type Global $aGUI_LineCTRL_W[$GUILinesNB][2] = [[1, 100], [1, 50]] ; Initial Width % of ctrls inside line Global $aGUI_LineCTRL_H[$GUILinesNB][2] = [[1, 50], [1, 50]] ; Initial Height % inside line - (Sum of % should be less or equal to 100% !) ; ************************************************************ Global $iParentGUI Global $iList1 Global $iList2 Global $space = 10, $count = 0 ; ************************************************************ $iParentGUI = GUICreate('Control settings checker', 600, 500, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SYSMENU, $WS_SIZEBOX, $WS_CAPTION), BitOR($WS_EX_STATICEDGE,$WS_EX_WINDOWEDGE)) ; $iList1 = GUICtrlCreateList("Line 1 - control 1 : LIST", 0, 0, -1, -1, _ $aGUI_LineCTRL_S[0][1], _ $aGUI_LineCTRL_eS[0][1]) $aGUI_LineCTRL_ID[0][1] = $iList1 ; $iList2 = GUICtrlCreateList("Line 2 - control 1 : LIST", 0, 0, -1, -1, _ $aGUI_LineCTRL_S[1][1], _ $aGUI_LineCTRL_eS[1][1]) $aGUI_LineCTRL_ID[1][1] = $iList2 ; ; ; ************************************************************ GUISetState(@SW_SHOW) GUIRegisterMsg($WM_SIZE, "_WM_SIZE") local $aGUIInfo = WinGetClientSize($iParentGUI) _ResetGUI($iParentGUI, $aGUIInfo[0], $aGUIInfo[1]) Local $nMsg While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; ************************************************************ Func _WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) Local Const $SIZE_MINIMIZED = 1 ; see MSDN -> https://msdn.microsoft.com/en-us/library/windows/desktop/ms632646(v=vs.85).aspx Switch $hWnd case $iParentGUI if $iwParam = $SIZE_MINIMIZED then Return $GUI_RUNDEFMSG Local $aClientSize[2] = [BitAND($ilParam, 65535), BitShift($ilParam, 16)] _ResetGUI($hWnd, $aClientSize[0], $aClientSize[1]) Return 0 ; If an application processes this message, it should return zero. case else Return $GUI_RUNDEFMSG ; don't forget that return value to avoid strange _ArrayDisplay view (and more ...) ! EndSwitch EndFunc ; _WM_SIZE Func _ResetGUI($hWnd, $ClientW_Width, $ClientW_Heigth) consolewriteDebug(1, @ScriptLineNumber, $count & " _ResetGUI()", " ------------------ ClientW-ClientH -> " & $ClientW_Width & "-" & $ClientW_Heigth & " -----------------------------------------------" & @crlf) $count += 1 GUISetState(@SW_LOCK, $hWnd) ; _UpdateGUI($hWnd, $ClientW_Width, $ClientW_Heigth) ; GUISetState(@SW_UNLOCK, $hWnd) _WinAPI_RedrawWindow($hWnd, 0, 0, $RDW_UPDATENOW + $RDW_INVALIDATE + $RDW_ALLCHILDREN) _DumpCurrentGUI($ClientW_Width, $ClientW_Heigth) ; EndFunc ; _ResetGUI Func _DumpCurrentGUI($iGUI_W, $iGUI_H) Local $leftX = 0 Local $TopY = 0 Local $WidthCTRL = 0 Local $HeightCTRL = 0 Local $aPos ; ; ////////////////// ; consolewriteDebug(1, @ScriptLineNumber, "> _DumpCurrentGUI()", " ->> ControlGetPos <<-" & @crlf) ; for $i = 0 to $GUILinesNB - 1 ; number of lines of controls with the same 'TOP' reference for $j = 1 to $aGUI_LineCTRL_S[$i][0] ; for each controls inside a line $aPos = ControlGetPos($iParentGUI, "", $aGUI_LineCTRL_ID[$i][$j]) $leftX = $aPos[0] $TopY = $aPos[1] $WidthCTRL = $aPos[2] $HeightCTRL = $aPos[3] consolewriteDebug(1, @ScriptLineNumber, "> ", "Line : " & $i+1 & " ==> (type)-> X-Y-W-H = (" & $aGUI_LineCTRL_T[$i][$j] & ")-" & $leftX & "-" & $TopY & "-" & $WidthCTRL & " (" & $aGUI_LineCTRL_W[$i][$j] & ") -" & $HeightCTRL & " (" & $aGUI_LineCTRL_H[$i][$j] & ")" & @crlf) next consolewriteDebug(1, @ScriptLineNumber, "> ", "*********************************" & @crlf) next EndFunc ; _DumpCurrentGUI Func _UpdateGUI($hWnd, $iGUI_W, $iGUI_H) Local $leftX = $space Local $TopY = $space Local $MaxH = 0 Local $WidthCTRL = 0 Local $HeightCTRL = 0 Local $percent = 0 Local $ci local $currentH local $swarning local $aPos ; ; ////////////////// ; consolewriteDebug(1, @ScriptLineNumber, "+ _UpdateGUI()", " ->> GUICtrlSetPos <<-" & @crlf) Local $WPercent = ($iGUI_W - (2) * $space) ; to keep at least a "space" border on left and on right Local $Hpercent = ($iGUI_H - ($GUILinesNB + 1) * $space) ; to keep at least a "space" border on top, on bottom and between the controls ; for $i = 0 to $GUILinesNB - 1 ; number of lines of controls ; ; *** ; for $j = 1 to $aGUI_LineCTRL_S[$i][0] ; for each controls inside a line ; ; Handle Width ; $percent = Number($aGUI_LineCTRL_W[$i][$j]) / 100 $WidthCTRL = Floor($percent * $WPercent) ; ; Handle Height ; $percent = Number($aGUI_LineCTRL_H[$i][$j]) / 100 $HeightCTRL = Floor($percent * $Hpercent) ; ; Move the control ; consolewriteDebug(1, @ScriptLineNumber, "+ ", "Line : " & $i+1 & " ==> (type)-> X-Y-W-H = (" & $aGUI_LineCTRL_T[$i][$j] & ")-" & $leftX & "-" & $TopY & "-" & $WidthCTRL & " (" & $aGUI_LineCTRL_W[$i][$j] & ") -" & $HeightCTRL & " (" & $aGUI_LineCTRL_H[$i][$j] & ")" & @crlf) ; GUICtrlSetPos($aGUI_LineCTRL_ID[$i][$j], _ $leftX, _ $TopY, _ $WidthCTRL, _ $HeightCTRL) ; ; Prepare next control inside the same line ; $leftX += $WidthCTRL + $space next ; ; Prepare next line of controls ; $TopY += $HeightCTRL + $space $leftX = $space consolewriteDebug(1, @ScriptLineNumber, "+ ", "*********************************" & @crlf) next EndFunc ; _UpdateGUI Func ConsoleWriteDebug($Debug, $lineNB, $flag, $msg) if $Debug then consolewrite($flag & "SLN: " & $lineNB & " - ") consolewrite($msg) endif EndFunc ; ConsoleWriteDebug