philw Posted July 25, 2009 Share Posted July 25, 2009 Hi, I want to check if a $WS_SIZEBOX control has been dragged to a new size. Is there a better way than repeatedly calling ControlGetPos() from a loop? I'm using OnEvent Mode. Thanks! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 25, 2009 Moderators Share Posted July 25, 2009 philw, You could register the WM_SIZE message: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $fResized = False ; When window is resized, run this function GUIRegisterMsg($WM_SIZE, "MY_WM_SIZE") ; Create GUI $hGUI = GUICreate("Test", 500, 500, -1, -1, $WS_SIZEBOX) $hLabel = GUICtrlCreateLabel("", 10, 10, 100, 100) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ; Show if resized If $fResized = True Then GUICtrlSetData($hLabel, "Resized") $fResized = False ; Clear the label every 2 secs AdlibRegister("Wipe", 2000) ; If you run Beta ;AdlibEnable("Wipe", 2000) ; If you run 3.3.0.0 EndIf WEnd Func MY_WM_SIZE($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam If $Hwnd = WinGetHandle($hGUI) Then $fResized = True Return $GUI_RUNDEFMSG EndFunc Func Wipe() GUICtrlSetData($hLabel, "") AdlibUnRegister("Wipe") ; If you run Beta ;AdlibDisable() ; If you run 3.3.0.0 EndFunc The label is cleared 2 secs after the resizing - if you resize too frequently you can get out of synch. But it will give you the idea. 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...
philw Posted July 25, 2009 Author Share Posted July 25, 2009 (edited) Thanks Melba23, but doesn't that method only work if the window is resized? I want to check if a control within the window (for example an edit control) is resized. I suppose I could set up a function which is called on mousedown or mouseup, and then check if the control is still the same size... but this seems a bit over the top. Edited July 25, 2009 by philw Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 25, 2009 Moderators Share Posted July 25, 2009 (edited) philw,I assumed that as a control is just another window, the same message would be sent - but it seems not. Sorry about that - I will have another think. M23Edit:Best I can do - there does not appear to be a control resize message:#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; Create GUI $hGUI = GUICreate("Test", 500, 500) $hLabel = GUICtrlCreateLabel("", 10, 10, 100, 100) $hEdit = GUICtrlCreateEdit("", 10, 200, 200, 200, $WS_SIZEBOX) GUISetState() $aStartSize = ControlGetPos($hGUI, "", $hEdit) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch $aSize = ControlGetPos($hGUI, "", $hEdit) If $aSize[2] <> $aStartSize[2] Or $aSize[3] <> $aStartSize[3] Then $aStartSize[2] = $aSize[2] $aStartSize[3] = $aSize[3] GUICtrlSetData($hLabel, "Resized") AdlibRegister("Wipe", 2000) EndIf WEnd Func Wipe() GUICtrlSetData($hLabel, "") AdlibUnRegister("Wipe") EndFuncBut no doubt someone out there will come along with a better solution in a while M23 Edited July 25, 2009 by Melba23 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...
philw Posted July 25, 2009 Author Share Posted July 25, 2009 (edited) Thanks for your help on this one! I thought it might be necessary to improvise. It's odd that there seems to be no control resize message, but such is life! Edited July 25, 2009 by philw 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