here is 2 examples :
e.g 1- this is a V1 script does the functionality on a GUI window :
Code: Select all
#NoEnv
#SingleInstance, Ignore
ClientWidth := 735 ; you only can set the size of the client area
ClientHeight := 245 ; you only can set the size of the client area
Gui, +AlwaysOnTop +Resize -MaximizeBox +ToolWindow +LastFound ; added +LastFound for WinGetPos
Gui, Show, w%ClientWidth% h%ClientHeight% NoActivate, Test GUI ; removed unnecessary xCenter and yCenter
WinGetPos, , , GuiWidth, GuiHeight ; get the real window size
OnMessage(WM_SIZING := 0x0214, "GuiSizing") ; handle WM_SIZING messages
Return
GuiClose:
ExitApp
GuiSizing(WP, LP) {
; http://msdn.microsoft.com/en-us/library/ms632647(v=vs.85).aspx
; WP : The edge of the window that is being sized.
; LP : A pointer to a RECT structure with the screen coordinates of the drag rectangle.
Global GuiWidth, GuiHeight
; The following values passed in WP will keep the ratio
Static KeepsRatio := {4: "TopLeft", 5: "TopRight", 7: "BottomLeft", 8: "BottomRight"}
; The following values passed in WP will resize horizontally
Static Horizontal := {1: "Left", 2: "Right"}
; The following values passed in WP will resize vertically
Static Vertical := {3: "Top", 6: "Bottom"}
Critical
; If the ratio will be kept, do nothing
If !KeepsRatio.HasKey(WP) {
; Get the new window rectangle
X := NumGet(LP + 0, 0, "Int")
Y := NumGet(LP + 0, 4, "Int")
W := NumGet(LP + 0, 8, "Int") - X
H := NumGet(LP + 0, 12, "Int") - Y
; If the window will be resized horizontally, adjust the height
If Horizontal.HasKey(WP)
NumPut(Y + (W / GuiWidth * GuiHeight), LP + 0, 12, "Int")
; Otherwise it will be resized vertically, so adjust the width
Else
NumPut(X + (H / GuiHeight * GuiWidth), LP + 0, 8, "Int")
}
}
Adjust Aspect Ratio to window size ??
Note :
- I found the GUI script mentioned as an example from here :
https://www.autohotkey.com/board/topic/92581-how-to-maintain-guis-aspect-ratio-when-resizing/
Any help to do so please!