Jump to content
Sign in to follow this  

GUI Resize Problems

Recommended Posts


I have a simple GUI box. The eventual goal is to be able to dynamically add buttons and other controls. Right now I just built a little GUI with two buttons... "Exit" and "Add" and when I click on "Add" I call WinMove which adds 20 pixels to the bottom which would account for the height of the new button. But when I do that, the controls place a little more space in between themselves. The bigger the window gets, the farther they get from each other. If I fiddle with setting options sometimes the buttons themselves resize.

So, is there a way to absolutley position my controls? If I tell the button it should be at 20 from the left, and 20 from the top and be 50 pixels wide and 20 pixels high it should always keep this position and dimensions.

I've also just tinkered with using WinMove to change the width dynamically and they also stretch horizontally too.

Here is an example of my code:

#include <GUIConstants.au3>

global $windowtitle = "Add Task Buttons"

Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode

$mainwindow = GuiCreate($windowtitle, 300, 300, 100, 100, -1)

GUICtrlCreateLabel("Click the Add Task", 30, 10)

GUISetCoord ( 0, 0)

$exitbutton = GUICtrlCreateButton("Exit", 60, 50, 60)

$addtask = GUICtrlCreateButton("Add Task", 60, 80, 60)

GUICtrlSetOnEvent($exitbutton, "EXITbutton")

GUICtrlSetOnEvent($addtask, "ADDTASKbutton")



While 1

  Sleep(1000)  ; Idle around


Func ADDTASKbutton()

  $pos = WinGetPos($windowtitle)

  WinMove($windowtitle,"", $pos[0], $pos[1], $pos[2], $pos[3]+20)


Func EXITbutton()

  If @GUI_WINHANDLE = $mainwindow Then




I'm sure the solution is simple. I'm fairly new to the GUI part of this so I probably just don't know what to look for. Also, is there an easier way to resize the GUI besides using WinMove?


Share this post

Link to post
Share on other sites

Found the solution by tearing into some other scripts.

if I add this to my code:

Opt("GuiResizeMode", 802)

everything stays put

Share this post

Link to post
Share on other sites

Just wanted to say thanks for sharing your solution :)

[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]

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