Jump to content
Sign in to follow this  
TheBreeder

Event window resize

Recommended Posts

TheBreeder

I have created the content of a window depending on the size of the window. If a button or field is addressed, I can find the size of the window and adapt the eventual controls. Is there an event that can be triggerd if a window is resized ?

Thanks


Elke vogel zingt zoals hij gebekt is !Als alleen die vogels zongen die het mooiste zingen zou het stil zijn in het bos.

Share this post


Link to post
Share on other sites
water

You can use something like "GUIRegisterMsg($WM_SIZE, 'WM_SIZE')" which will run the function "WM_SIZE($hWnd, $Msg, $wParam, $lParam)" when your window is resized.

See this post for an example.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
TheBreeder

You can use something like "GUIRegisterMsg($WM_SIZE, 'WM_SIZE')" which will run the function "WM_SIZE($hWnd, $Msg, $wParam, $lParam)" when your window is resized.

See this post for an example.

this will give me the new actual size, but I'm not triggerd when the users has resized the window. I have to use waits and thing like that to be able to detect a change.


Elke vogel zingt zoals hij gebekt is !Als alleen die vogels zongen die het mooiste zingen zou het stil zijn in het bos.

Share this post


Link to post
Share on other sites
water

When I run the following code the function "MY_WM_SIZE" is called as long as the user resizes the window.

Do you want to know when the user has finished resizing the window? Then I think you'll have to combine the above code with code to check if the user has released the left mouse button.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Authenticity

Windows post a message only when the user change the window size. If the user is resizing the window but the mouse button remains pressed, you won't be notified about it with WM_SIZE because it's not triggered until the user release the mouse button. You can use GUICtrlSetResizing to dock or otherwise move the control relative to the window width or height.

Edited by Authenticity

Share this post


Link to post
Share on other sites
water

If the user is resizing the window but the mouse button remains pressed, you won't be notified about it with WM_SIZE because it's not triggered until the user release the mouse button.

I don't think this is true. I've inserted a consolewrite at the beginning of the MY_WM_SIZE function (see my previous post fo the link) and I get messages on the console as long as i resize the GUI AND the mouse button is pressed.

I'm running Autoit 3.3.0 on Windows XP.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
TheBreeder

I don't think this is true. I've inserted a consolewrite at the beginning of the MY_WM_SIZE function (see my previous post fo the link) and I get messages on the console as long as i resize the GUI AND the mouse button is pressed.

I'm running Autoit 3.3.0 on Windows XP.

I get it work.

Thanks all for your input.

This will close for me the topic.

Richard


Elke vogel zingt zoals hij gebekt is !Als alleen die vogels zongen die het mooiste zingen zou het stil zijn in het bos.

Share this post


Link to post
Share on other sites
Melba23

Authenticity,

I am with you on this one.

M23

P.S. Not that I am ever really against you, you understand! :-)


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Zedna

Windows post a message only when the user change the window size. If the user is resizing the window but the mouse button remains pressed, you won't be notified about it with WM_SIZE because it's not triggered until the user release the mouse button. You can use GUICtrlSetResizing to dock or otherwise move the control relative to the window width or height.

I think this may be affected by Windows' option "Draw content of windows while moving".

I have always ON this option and WM_SIZE is triggered all the time I'm resizing window.

Edited by Zedna

Share this post


Link to post
Share on other sites
Melba23

Zedna,

After some minutes of fruitless searching, please give me a hint as to where that option is hidden (on Vista if possible!) and I will tell you if it is on/off on my system!

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Authenticity

I don't think this is true. I've inserted a consolewrite at the beginning of the MY_WM_SIZE function (see my previous post fo the link) and I get messages on the console as long as i resize the GUI AND the mouse button is pressed.

I'm running Autoit 3.3.0 on Windows XP.

The code you've posted calling the event twice each time, once upon user action and once because of WinMove function call.

Both, your code and this one are calling the event only when the user is releasing the mouse button:

#include <WindowsConstants.au3>

GUIRegisterMsg($WM_SIZE, 'onresize')

Dim $hGUI = GUICreate('Test', 100, 100, Default, Default, BitOR($WS_POPUP, $WS_THICKFRAME))
Dim $iCount = 0

GUISetState()

Do
Until GUIGetMsg() = -3

Func onresize($hwnd, $iMsg, $iwParam, $ilParam)
    ConsoleWrite('Data ' & $iCount & @LF)
    $iCount += 1
    
    Return 'GUI_RUNDEFMSG'
EndFunc

I guess something is not clear, ;].

Edited by Authenticity

Share this post


Link to post
Share on other sites
martin

Zedna,

After some minutes of fruitless searching, please give me a hint as to where that option is hidden (on Vista if possible!) and I will tell you if it is on/off on my system!

M23

I don't know about Vista but in XP the setting is in desktop Properties, Appearance, Effect, showwindows contents while dragging. If you don't have show windows contents while dragging then WM_SIZE is only sent to a window at the start of resizing and at the end just before sending WM_EXITSIZEMOVE.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
Authenticity

Correct martin, sorry for misleading whoever I'm misleading here ;].

Share this post


Link to post
Share on other sites
Zedna

Zedna,

After some minutes of fruitless searching, please give me a hint as to where that option is hidden (on Vista if possible!) and I will tell you if it is on/off on my system!

M23

Free translation from my Czech Windows:

WIN98:

menu Start/Settings/Options of folder --> Tab "Show" --> checkbox "Show content of window while dragging"

WINXP:

right click on "This computer" on the desktop --> Tab "?Specify?" --> In group "Performance" button "Setup or Setting" --> Tab "Visual effects" --> checkbox "Show content of window while dragging"

Edited by Zedna

Share this post


Link to post
Share on other sites
Melba23

martin,

Thanks. I found "Show window contents while dragging" under "Personalization - Window Color and Appearance - Appearance - Effects". It is "On".

On closer inspection of a script using WM_SIZE, I do appear to get multiple returns from the Registered function as I resize a window. However, I use the function to set a flag which I check in the main While...WEnd loop - and this is only triggered once, as the mouse button is released.

The snippets concerned:

While 1
    
    Switch GUIGetMsg()
    ; various Cases

; Look for resize message
    If $fResized Then       
        ConsoleWrite("Loop" & @CRLF) ; <<<<< Added to check
        ; Other code to reorganise/resize the GUI contents (tabs and a listview)

        ; Reset flag
        $fResized = False
    EndIf
WEnd

; -------

Func MY_WM_SIZE($hWnd, $Msg, $wParam, $lParam)
    
    $iGUIWidth = BitAND($lParam, 0xFFFF)
    $iGUIHeight = BitShift($lParam, 16)
; Set flag
    $fResized = True
        
    ConsoleWrite("Function" & @CRLF) ; <<<<< Added to check
        
    Return $GUI_RUNDEFMSG
    
EndFunc  ;==>MY_WM_SIZE

The script works perfectly - the internal GUI reorgaisation only taking place after mouse button release. Does this GUIRegisterMsg code take over the script in much the same way as a HotKetSet? That could explain why the While...WEnd loop does not even get a chance to check the flag until after mouse button release - which gives the impression of a single return from the function.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×