Jump to content

Lock gui width when resize


Kyan
 Share

Recommended Posts

Hi, its possible to lock a GUI width only allowing to change is height?

And how can I set the minimal size as the window can be? yes I look in the help file and just found resize dock positions, etc...not any way to lock

I also tried with GUICtrlSetResizing(-1,$GUI_DOCKWIDTH), but nothing changed...

thanks in advance

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Link to comment
Share on other sites

You can do it this way.

; Add this line near the top of your script
GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") ; Monitors resizing of the GUI


Func _WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam) ; used to limit the minimum size of the GUI
    #forceref $hWnd, $Msg, $wParam, $lParam
    Local $iWidth = 300 ; minimum width setting
    Local $iHeight = 600 ; minimum height setting
    If $hWnd = $YourGUI
        Local $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
        DllStructSetData($tagMaxinfo, 7, $iWidth) ; min width
        DllStructSetData($tagMaxinfo, 8, $iHeight) ; min height
                DllStructSetData($tagMaxinfo, 9, $iWidth) ; max width
                DllStructSetData($tagMaxinfo, 10, 99999) ; max height
        Return $GUI_RUNDEFMSG
    EndIf
EndFunc   ;==>_WM_GETMINMAXINFO

Add this to the script and change the values to what you want your GUI to be sized to, also change the variable $YourGUI in this line "If $hWnd = $YourGUI" to the handle to your GUI.

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

You can do it this way.

; Add this line near the top of your script
GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") ; Monitors resizing of the GUI


Func _WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam) ; used to limit the minimum size of the GUI
#forceref $hWnd, $Msg, $wParam, $lParam
Local $iWidth = 300 ; minimum width setting
Local $iHeight = 600 ; minimum height setting
If $hWnd = $YourGUI
Local $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
DllStructSetData($tagMaxinfo, 7, $iWidth) ; min width
DllStructSetData($tagMaxinfo, 8, $iHeight) ; min height
DllStructSetData($tagMaxinfo, 9, $iWidth) ; max width
DllStructSetData($tagMaxinfo, 10, 99999) ; max height
Return $GUI_RUNDEFMSG
EndIf
EndFunc ;==>_WM_GETMINMAXINFO

Add this to the script and change the values to what you want your GUI to be sized to, also change the variable $YourGUI in this line "If $hWnd = $YourGUI" to the handle to your GUI.

Thank you sir, works great :D

In minimum width I need to set my gui width + 16, and for height + 38, any reasons for this? :o

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Link to comment
Share on other sites

The borders take up space, and the title bar if any takes up more space. This function limits the entire GUI, while your GUICreate only specifies the client area.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

The borders take up space, and the title bar if any takes up more space. This function limits the entire GUI, while your GUICreate only specifies the client area.

never thought in that

btw, there's any reason by when I reasize my gui, every controls (labels, inputs, groups, buttons, pic...) blink?

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Link to comment
Share on other sites

btw, there's any reason by when I reasize my gui, every controls (labels, inputs, groups, buttons, pic...) blink?

They get painted again and again and hence you see the blink, you can use the $WS_EX_COMPOSITED ex-style upon creating the GUI it would allow double-buffer for painting and hence you wont see the flickering, but the style has some issues, use with caution

Regards :)

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

They get painted again and again and hence you see the blink, you can use the $WS_EX_COMPOSITED ex-style upon creating the GUI it would allow double-buffer for painting and hence you wont see the flickering, but the style has some issues, use with caution

Regards :)

Thanks for the explanation :), I use it as ex-style and my gui stop responding :s

this is the styles I applied:

GUICreate("Title", width, height, -1, -1,BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP),$WS_EX_COMPOSITED)

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

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...