Moderators Melba23 Posted November 21, 2021 Author Moderators Share Posted November 21, 2021 Efo74, It seems that intercepting the Win-D button press, or the "show desktop" taskbar button is not a trivial task - so I have developed a workaround which I hope will satisfy you. But first a little explanation of what goes on in the UDF so you can understand why this workaround works. When you call the _GUIScrollbars_Minimize function it stores the current position of the scrollbars and then sets them to their original position so that Windows cannot mess them about. Running the _GUIScrollbars_Restore function resets the scrollbars to their stored position. What happens with Win-D is that the system minimizes the GUI before the UDF has a chance to store the scrollbar positions and sets the scrollbars to some random position, which is why you need the _GUIScrollbars_Minimize function in the first place. Then when the GUI itself gets the minimize event it stores these inaccurate scrollbar positions which, when restored later, give you the erroneous scrollbar positions. Complicated eh? So my workaround is to allow the UDF to intercept the GUI being minimized by the system and to store the scrollbar positions at that point and then prevent the minimize event of the GUI firing the function a second time and thus storing the random positions generated. Here is the example code amended to make this happen - I hope it is self explanatory, but please do ask if you have any questions: expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIScrollbars_Ex.au3> Global $bWD = False ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Create a flag to show if Win-D has been invoked ; Create GUI with red background $hGUI = GUICreate("Test", 500, 500) GUISetBkColor(0xFF0000, $hGUI) ; Create a 1000x1000 green label GUICtrlCreateLabel("", 0, 0, 1000, 1000) GUICtrlSetBkColor(-1, 0x00FF00) GUIRegisterMsg($WM_SIZE, "_WM_SIZE") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<< Look for the Win-D MINIMIZE message being sent to the GUI GUISetState() _GUIScrollbars_Generate($hGUI, 1000, 1000) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_RESTORE,$GUI_EVENT_MAXIMIZE _GUIScrollbars_Restore($hGUI,True,True) Case $GUI_EVENT_MINIMIZE ; Check the flag If $bWD Then ; Do NOT react if the Win-D message was already actioned so as not to overwrite the scrollbar positions ; Buit do reset the flag $bWD = False Else ; Run the function to store the current location of the scrollbars and set them to their initial positions _GUIScrollbars_Minimize($hGUI) EndIf EndSwitch WEnd Func _WM_SIZE($hWnd, $iMsg, $wParam, $lParam) ; <<<<<<<<<<<<<<<<<<<<<<<< Look to see if the GUI is minimized If $hWnd = $hGUI And BitAnd(WinGetState($hGUI), $WIN_STATE_MINIMIZED) Then ; Run the function to store the current location of the scrollbars and set them to their initial positions _GUIScrollbars_Minimize($hGUI) ; Set a flag to show this has been done $bWD = True EndIf EndFunc Does this work for you too? I will keep looking how AutoIt might detect the Win-D and taskbar button activation - and to see if I can make the workaround a little more elegant if we have to go that way. 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...
Efo74 Posted November 21, 2021 Share Posted November 21, 2021 One word: PERFECT !!!. This is just what I was looking for. I had tried some solutions too ... but I had made the problem worse ... 😟 Thanks Infinite. :rolleyes: Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 21, 2021 Author Moderators Share Posted November 21, 2021 Efo74, Glad I could produce something for you so quickly. M23 Efo74 1 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...
Moderators Melba23 Posted November 22, 2021 Author Moderators Share Posted November 22, 2021 (edited) Efo74, Here is a new version of the UDF which does all the work for you - it is based on the previous code I posted but everything is now internal to the UDF code. For me it works with your original script without problem: Please try it and let me know what you think. Other opinions also welcome. M23 Edited November 23, 2021 by Melba23 Beta code removed 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...
Efo74 Posted November 22, 2021 Share Posted November 22, 2021 Thanks, sorry for the delay. With great pleasure I download your new job and run the tests, although I'm sure it will work perfectly. :rolleyes: Link to comment Share on other sites More sharing options...
Efo74 Posted November 22, 2021 Share Posted November 22, 2021 I confirm. I would say it works perfectly. 😃 Now I have to study your source code for a while. Thank you so much. for me this was a very annoying problem and one that I would not have been able to solve without your intervention. :rolleyes: Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 23, 2021 Author Moderators Share Posted November 23, 2021 Efo74, Working on this problem has led me to what I believe is a more elegant way to deal with minimizing and restoring GUIs which have scrollbars generated by this UDF. No longer do you have to look for the MiNIMIZE/RESTORE events - you just run an event monitor function in your idle loop (like many other of my UDFs). Here is the modified UDF: GUIScrollbars_Ex_Mod.au3 And here is an example script: #include <GuiConstantsEx.au3> #include <GUIScrollbars_Ex_Mod.au3> $hGUI_1 = GUICreate("Test", 500, 500, 100, 100) GUISetBkColor(0xFF0000, $hGUI_1) GUICtrlCreateLabel("", 0, 0, 1000, 1000) GUICtrlSetBkColor(-1, 0x00FF00) GUISetState() $hGUI_2 = GUICreate("Test", 300, 300, 700, 500) GUISetBkColor(0x0000FF, $hGUI_2) GUICtrlCreateLabel("", 0, 0, 500, 500) GUICtrlSetBkColor(-1, 0xFFFF00) GUISetState() _GUIScrollbars_Generate($hGUI_1, 500, 1000) _GUIScrollbars_Generate($hGUI_2, 500, 500) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch _GUIScrollbars_EventMonitor() WEnd Does that meet with you requirements? Does anyone else have an opinion? 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...
Efo74 Posted November 24, 2021 Share Posted November 24, 2021 Hi, tried this version ... right now I can't be precise (I'm in a hurry and I have to go to work, I show up in the evening with a piece of code that displays the problem), but it doesn't seem to work as well as the previous version . the scrollbars are always restored both (even if only one was created) also the controls inside are not repositioned correctly ... all very smoky as a description but for now that's all I can say. In summary: it doesn't seem to work as well as it used to. Thanks, I'll be back for a more precise description. :rolleyes: Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 24, 2021 Author Moderators Share Posted November 24, 2021 Efo74, Please do post your script as I have seen nothing like that in my tests. 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...
Efo74 Posted November 25, 2021 Share Posted November 25, 2021 Sorry for the delay. This weekend I will test the library thoroughly and provide correct feedback, and possibly a script as well. :rolleyes: Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 25, 2021 Author Moderators Share Posted November 25, 2021 Efo74, No rush. 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...
Moderators Melba23 Posted January 27, 2022 Author Moderators Share Posted January 27, 2022 [New Version] - 27 Jan 22 New: The GUIScrollbar_Ex UDF now recognises Win-D and taskbar desktop clearance commands and runs the correct minimize/restore code automatically. The previous UDF _Minimize and _Restore commands have been superceded by a single _EventMonitor function which runs in the script idle loop. This is a script-breaking change, but I hope that the additional functionality is worth the small effort it will take to alter your scripts. New UDFs and examples in the first post. M23 Efo74 1 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...
pixelsearch Posted April 17, 2022 Share Posted April 17, 2022 (edited) Hi Melba23, I'm facing a problem with your function _GUIScrollbars_Restore() found in GUIScrollbars_Size.au3 and I found a solution to fix it. The issue doesn't appear when there is only 1 scrollbar to restore. For example, the script GUIScrollbars_Size_Example_2.au3 works fine because it only got a vertical scrollbar, so its code restores the scrollbar & the content of the GUI at their correct position, after the vertical scrollbar had been moved and the GUI minimized : Case $GUI_EVENT_RESTORE _GUIScrollbars_Restore($hGUI, True, False) The issue happens when there are 2 scrollbars to restore, for example in the 3rd script you shared a few days ago (now found in this thread) and you introduced it with these words "And here is an example which is dynamic in both directions" : expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIScrollBars.au3> #include <ScrollBarConstants.au3> #include <WinAPISys.au3> #include "GUIScrollbars_Size.au3" HotKeySet("^+R", "_Increase_Rows") HotKeySet("^+C", "_Increase_Cols") ; Get size of scrollbars Global $iScroll_Width = _WinAPI_GetSystemMetrics(2) ; Width of VScrollbar: SM_CXVSCROLL Global $iScroll_Height = _WinAPI_GetSystemMetrics(3) ; Height of HScrollbar: SM_CYHSCROLL ; Set key parameters Global $i_Key_Width = 40 Global $i_Key_Height = 20 Global $i_Rows = 12 Global $i_Cols = 8 ; Calculate the size of the full GUI to be scrolled Global $i_Gui_Width = $i_Key_Width * $i_Cols Global $i_Gui_Height = $i_Key_Height * $i_Rows ; Create the GUI with the size of the aperture to be used Global $hGUI = GUICreate("Test", 200, 200) GUISetState() $aRet = _GUIScrollbars_Size($i_Gui_Width, $i_Gui_Height, 200, 200) ; Parameters: $i_Gui_Width - Width of underlying GUI ; $i_Gui_Height - Vertical size of underlying GUI ; 200 - Width of aperture GUI ; 200 - Height of aperture GUI ; Register the handlers GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") GUIRegisterMsg($WM_HSCROLL, "_Scrollbars_WM_HSCROLL") ; Create scrollbars _GUIScrollBars_Init($hGUI) ;Show and set parameters for horizontal scrollbar _GUIScrollBars_ShowScrollBar($hGUI, $SB_HORZ, True) _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_HORZ, $aRet[0]) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_HORZ, $aRet[1]) ; And then for vertical _GUIScrollBars_ShowScrollBar($hGUI, $SB_VERT, True) _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $aRet[3]) ; Create keys _Create_Keys() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_RESTORE ; Still needed if you use the _Size UDF ; _GUIScrollbars_Restore($hGUI, True, False) ; personal note : probably a typo... _GUIScrollbars_Restore($hGUI, True, True) ; ...as there are 2 scrollbars EndSwitch WEnd Func _Increase_Cols() ; Save scrollbar positions and set to 0 Local $iHorz = _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_HORZ) Local $iVert = _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_VERT) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, 0) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, 0) ; Save current final col Local $iCurrCols = $i_Cols ; Add rows $i_Cols += 4 ; Create the new keys _Create_Keys(0, $iCurrCols) ; Calculate the new height $i_Gui_Width = $i_Key_Width * $i_Cols ; Use the UDF to get the new scrollbar parameters $aRet = _GUIScrollbars_Size($i_Gui_Width + $iScroll_Width, 0, 200, 200) ; And set them _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_HORZ, $aRet[0]) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_HORZ, $aRet[1]) ; Reset positions _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, $iHorz) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, $iVert) EndFunc Func _Increase_Rows() ; Save scrollbar positions and set to 0 Local $iHorz = _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_HORZ) Local $iVert = _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_VERT) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, 0) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, 0) ; Save current final row Local $iCurrRows = $i_Rows ; Add rows $i_Rows += 4 ; create the new keys _Create_Keys($iCurrRows) ; Calculate the new height $i_Gui_Height = $i_Key_Height * $i_Rows ; Use the UDF to get the new scrollbar parameters $aRet = _GUIScrollbars_Size(0, $i_Gui_Height + $iScroll_Height, 200, 200) ; And set them _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $aRet[3]) ; Reset positions _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, $iHorz) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, $iVert) EndFunc Func _Create_Keys($iCurrRows = 0, $iCurrCols = 0) ; Create Keys For $row = $iCurrRows To $i_Rows - 1 For $col = $iCurrCols To $i_Cols - 1 $s_Key_Name = $row + 1 & "." & $col + 1 GUICtrlCreateButton($s_Key_Name, ($col) * $i_Key_Width, ($row) * $i_Key_Height, $i_Key_Width, $i_Key_Height) GUICtrlSetFont(-1, Default, 900) ; Bold Next Next EndFunc ; ==> _Create_Keys Func _Scrollbars_WM_HSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $xChar, $xPos Local $Page, $Pos, $TrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $xChar = $__g_aSB_WindowInfo[$iIndex][2] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $Page = DllStructGetData($tSCROLLINFO, "nPage") $xPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $xPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_LINELEFT DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINERIGHT DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGELEFT DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGERIGHT DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($hWnd, $xChar * ($xPos - $Pos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_HSCROLL Func _Scrollbars_WM_VSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $yChar, $yPos Local $Min, $Max, $Page, $Pos, $TrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $yChar = $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") $Page = DllStructGetData($tSCROLLINFO, "nPage") $yPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $yPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_TOP DllStructSetData($tSCROLLINFO, "nPos", $Min) Case $SB_BOTTOM DllStructSetData($tSCROLLINFO, "nPos", $Max) Case $SB_LINEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos)) $yPos = $Pos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_VSCROLL The solution I found is the one below, where some instructions are executed while the scrollbars are hidden. The code should be completed to cover all cases (when only a scrollbar is needed) but well... you got the idea. Case $GUI_EVENT_RESTORE ; Still needed if you use the _Size UDF _GUIScrollBars_ShowScrollBar($hGUI, $SB_BOTH, False) Local $nH_Pos = _GUIScrollBars_GetScrollPos($hGUI, $SB_HORZ) Local $nV_Pos = _GUIScrollBars_GetScrollPos($hGUI, $SB_VERT) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, 0) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, 0) _GUIScrollBars_ShowScrollBar($hGUI, $SB_BOTH, True) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, $nH_Pos) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, $nV_Pos) Thanks for sharing your thoughts about this and I apologize if something I wrote is incorrect. For the record, I tested your good example GUIScrollbars_Ex_Example_2.au3 , based on GUIScrollbars_Ex.au3 and _GUIScrollbars_EventMonitor() : everything goes well with its 2 scrollbars after minimize & restore, but as you wrote elsewhere : "To have correctly-sized scrollbars in a fixed size GUI with a dynamic number of internal controls you need to use _GUIScrollbars_Size, not _GUIScrollbarsEx" Have a great sunday everybody Edit: splitting the Minimize-Restore code in both Case(s) seem to display faster when restoring (variables Local $nH_Pos & Local $nV_Pos to be scripted better but enough for today) Case $GUI_EVENT_MINIMIZE _GUIScrollBars_ShowScrollBar($hGUI, $SB_BOTH, False) Local $nH_Pos = _GUIScrollBars_GetScrollPos($hGUI, $SB_HORZ) Local $nV_Pos = _GUIScrollBars_GetScrollPos($hGUI, $SB_VERT) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, 0) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, 0) Case $GUI_EVENT_RESTORE _GUIScrollBars_ShowScrollBar($hGUI, $SB_BOTH, True) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, $nH_Pos) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, $nV_Pos) Edited April 17, 2022 by pixelsearch typo taurus905 1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 17, 2022 Author Moderators Share Posted April 17, 2022 (edited) pixelsearch, What an interesting discovery that you seem to need to hide/show BOTH scrollbars using $SB_BOTH to get it to work properly. Good detective work on your behalf. But I notice that, just as with GUIScrollbarsEx, the RESTORE is not correct when using Win-D or the taskbar "hide all" button. I may have to register WM_SIZE as I did a couple of months ago with the GUIScrollbarsEx code. Needs a bit of thought first. I sometime wish I had written UDFs for less flaky controls than scrollbars and ListViews are both are real pains to work with - although that is probably why there were no complex UDFs for them beforehand. M23 Edit: I think it might be a good idea to write a 3rd UDF for the package which will deal with MINIMIZE/RESTORE cycles for initiated GUIs - that way the _SIZE UDF retains its current stand-alone form. Something to keep me occupied over the next few days..... Edited April 17, 2022 by Melba23 taurus905 and pixelsearch 2 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...
pixelsearch Posted April 17, 2022 Share Posted April 17, 2022 (edited) 2 hours ago, Melba23 said: But I notice that, just as with GUIScrollbarsEx, the RESTORE is not correct when using Win-D or the taskbar "hide all" button. Very true, so let's try plan B Local $nH_Pos, $nV_Pos, $iIncMini = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch If BitAND(WinGetState($hGUI), $WIN_STATE_MINIMIZED) Then ; Minimize button, Win-D, hide all $iIncMini += 1 If $iIncMini = 1 Then _GUIScrollBars_ShowScrollBar($hGUI, $SB_BOTH, False) $nH_Pos = _GUIScrollBars_GetScrollPos($hGUI, $SB_HORZ) $nV_Pos = _GUIScrollBars_GetScrollPos($hGUI, $SB_VERT) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, 0) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, 0) EndIf Else ; not Minimized If $iIncMini Then $iIncMini = 0 _GUIScrollBars_ShowScrollBar($hGUI, $SB_BOTH, True) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, $nH_Pos) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, $nV_Pos) EndIf EndIf WEnd It seems to cover all cases and restore correctly, could you please test it on your computer ? Edited April 17, 2022 by pixelsearch Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 17, 2022 Author Moderators Share Posted April 17, 2022 pixelsearch, That is essentially the same code as the WM_SIZE handler and _EventMonitor function I added to GUIScrollbarsEx. However, I am concerned by the case of having 2 or more GUIs with scrollbars in the same script - I think there might need to be an array holding all of the "likely to be minimized with scrollbars" GUIs so that they can all be dealt with when one of the universal "minimize" commands is actioned. But that will be tomorrow's task. 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...
Moderators Melba23 Posted April 18, 2022 Author Moderators Share Posted April 18, 2022 (edited) And here is the result of my labours - an additional UDF, GUIScrollbars_MinRes, to deal with the minimize/restore cycle in both _Ex and _Size scripts. In this zip you have 2 examples, one each for _Ex and _Size, along with the new file and the modified _Ex and _Size UDFs: Over to readers to try and break it - which I am sure you will! M23 Edited April 19, 2022 by Melba23 Alpha code removed 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...
pixelsearch Posted April 18, 2022 Share Posted April 18, 2022 (edited) Well done M23 I admire your ability to juggle with all these custom scrollbars functions Both test examples (in MinRes.zip) work fine when their original code is used. No matter the way you minimize the GUI, the scrollbars are correctly restored. Now, concerning MinRes_Size_Example.au3 : If the user increases for example the $i_Aperture_Height parameter (I think he's allowed to) then the GUI will first be displayed without a vertical scrollbar (which is a normal behaviour) : ; Global $i_Aperture_Height = 200 Global $i_Aperture_Height = 300 After that, adding rows (Ctrl+Shift+R) will be problematic. For example with an increment of 2 rows : ; Add rows ; $i_Rows += 4 $i_Rows += 2 "MinRes_Size_Example.au3" (135) : ==> Subscript used on non-accessible variable.: _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_VERT, $aRet^ ERROR Personal : this error may not be found on all computers, depending on the line height value (which may not be the same in different OS) With an increment of 4 rows (as in the original code) there won't be a fatal error but other display issues will be shown when the vertical scrollbar appears, as you'll probably notice on your computer (I'm not adding pics below as it takes place, but if you want me to, I will) Just let me add this and it's very honest : please never think that I like to report bugs. In fact I dislike it a lot and I'm doing it with only one thing in mind, which is to help the concerned person and hope his script will work better. No more, no less. Edited April 18, 2022 by pixelsearch Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 19, 2022 Author Moderators Share Posted April 19, 2022 pixelsearch, Quote please never think that I like to report bugs Delighted that you do - I can never find them all! I was pretty sure that there would be problems when adding a scrollbar - for the reasons explained in the tutorial in the first post. Windows shrinks the client area content to fit the reduced dimensions and you need to use the correction values returned by the _Size call on any newly created controls. In this case I am thinking that simply redrawing all the buttons might be the best way to proceed, but I am keeping an open mind as I test more. I believe I have fixed the array access error by amending the _Size UDF to ignore the passed values if there is no need for a scrollbar in that axis. But the first time the scrollbar is needed it seems to be badly sized and there is still the problem of the mis-sized controls mentioned above in subsequent additions. Nose back to the grindstone this evening! 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...
Moderators Melba23 Posted April 19, 2022 Author Moderators Share Posted April 19, 2022 And the next instalment to try and break: MinRes.zip Changes: The _Size example now allows you to subtract as well as add columns and rows. The _EventMonitor function no longer needs a "$iMode" parameter - all done internally and so easier for the novice. The _Size UDF should no longer give the subscript error shown above. There still seems to be a problem the first time a scrollbar is created or removed although subsequent changes do appear get the correct sizing. Something to work on over the week! 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