Jump to content

WinMove resize stretch problem


Recommended Posts

Hi, when using WinMove() to resize the window it will stretch all objects to fit in the stretched window.

How can I make it so the objects don't stretch when I make the window bigger?

Huh! :)

It certainly does! I expected that to be only graphic controls and the others to stay put, but it's the exact opposite! Demo:

#include <guiconstants.au3>

; Create GUI
$hGui = GUICreate("Rubber GUI Test", 400, 230, 200, 200)
GUICtrlCreateLabel("Some sample controls:", 10, 10, 200, 20)
GUICtrlCreateInput("", 10, 40, 150, 20)
GUICtrlCreateGraphic(10, 70, 380, 110)
GUICtrlSetBkColor(-1, 0xffffff)
GUICtrlSetColor(-1, 0)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_PIE, 58, 50, 40, -60, 90)
$Quit = GUICtrlCreateButton("QUIT", 175, 190, 50, 30)
GUISetState()

Global $WinPos = 0
Global $Time = TimerInit()
While 1
    If GUIGetMsg() = $Quit Then Exit
    If TimerDiff($Time) > 3000 Then _ToggleWinPos()
    Sleep(20)
WEnd

Func _ToggleWinPos()
    $Time = TimerInit()
    $WinPos = Not $WinPos
    If $WinPos Then
        WinMove("Rubber GUI Test", "", 200, 200, 600, 400)
    Else
        WinMove("Rubber GUI Test", "", 200, 200, 400, 230)
    EndIf
EndFunc   ;==>_ToggleWinPos

Interesting... :D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

It's not any better when you Maximize/Normalize the window:

#include <guiconstants.au3>

; Create GUI
$hGui = GUICreate("Rubber GUI Test", 400, 230, 200, 200)
GUICtrlCreateLabel("Some sample controls:", 10, 10, 200, 20)
GUICtrlCreateInput("", 10, 40, 150, 20)
GUICtrlCreateGraphic(10, 70, 380, 110)
GUICtrlSetBkColor(-1, 0xffffff)
GUICtrlSetColor(-1, 0)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_PIE, 58, 50, 40, -60, 90)
$Quit = GUICtrlCreateButton("QUIT", 175, 190, 50, 30)
GUISetState(@SW_SHOWNORMAL)

Global $WinPos = 0
Global $Time = TimerInit()
While 1
    If GUIGetMsg() = $Quit Then Exit
    If TimerDiff($Time) > 3000 Then _ToggleWinPos()
    Sleep(20)
WEnd

Func _ToggleWinPos()
    $Time = TimerInit()
    $WinPos = Not $WinPos
    If $WinPos Then
        GUISetState(@SW_MAXIMIZE)
    Else
        GUISetState(@SW_SHOWNORMAL)
    EndIf
EndFunc   ;==>_ToggleWinPos

Time for the brainy people to step in and tell us mere mortals what the heck is going on...

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

:) Aha!!! :D

The answer is: GUICtrlSetResizing(controlID, resizing). Came across it while looking for Opt() settings that might be related.

:D

Fixed Demo:

#include <guiconstants.au3>

; Create GUI
Global $W = 400, $H = 230, $X = 200, $Y = 200
Global $hGui = GUICreate("Rubber GUI Test", $W, $H, $X, $Y)
GUICtrlCreateLabel("Some sample controls:", 10, 10, 200, 20)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlCreateInput("", 10, 40, 150, 20)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlCreateGraphic(10, 70, 380, 110)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlSetBkColor(-1, 0xffffff)
GUICtrlSetColor(-1, 0)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_PIE, 58, 50, 40, -60, 90)
$Quit = GUICtrlCreateButton("QUIT", 175, 190, 50, 30)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUISetState()

Global $WinPos = 0
Global $Time = TimerInit()
While 1
    If GUIGetMsg() = $Quit Then Exit
    If TimerDiff($Time) > 3000 Then _ToggleWinPos()
    Sleep(20)
WEnd

Func _ToggleWinPos()
    $Time = TimerInit()
    $WinPos = Not $WinPos
    If $WinPos Then
        WinMove("Rubber GUI Test", "", $X, $Y, $W + 200, $H + 200)
    Else
        WinMove("Rubber GUI Test", "", $X, $Y, $W + 4, $H + 30)
    EndIf
EndFunc   ;==>_ToggleWinPosoÝ÷ Ú«·#ÒN§Ëhé`y.q©íjG¨ºÛaxe
ÚåIëQzȳx¢·r(Ú輬zÛbay×jém~íì!¢WP®¶­sc²7&VFRuT¤÷BgV÷C´wV&W6¦TÖöFRgV÷C²Âb33c´uTôDô4´Ä¤vÆö&Âb33cµrÒCÂb33c´Ò#3Âb33cµÒ#Âb33cµÒ#¤vÆö&Âb33c¶wVÒuT7&VFRgV÷Cµ'V&&W"uTFW7BgV÷C²Âb33cµrÂb33c´Âb33cµÂb33cµ

But notice the offsets that have to be added to the Width and Height. When doing WinMove, the pixel width of the borders and menu bar are not automatically added as they are in GuiCreate().

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

But notice the offsets that have to be added to the Width and Height. When doing WinMove, the pixel width of the borders and menu bar are not automatically added as they are in GuiCreate().

Thanks your reply works wonders. When creating offsets though I found out that it depends on the windows theme you are using (classic vs xp). I'm not sure if the other operating system offsets would be different too.

Now I have another small question. Instead of using $GUI_DOCKALL, is there one to do just the opposite? I still want a few of my button to move when the resize happens.

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