Jump to content

Event window resize


Recommended Posts

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.

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Moderators

Authenticity,

I am with you on this one.

M23

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...