Jump to content

Recommended Posts

Posted

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")

GUISwitch($mainwindow)

GUISetState(@SW_SHOW)

While 1

  Sleep(1000)  ; Idle around

WEnd

Func ADDTASKbutton()

  $pos = WinGetPos($windowtitle)

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

EndFunc

Func EXITbutton()

  If @GUI_WINHANDLE = $mainwindow Then

    Exit

  EndIf

EndFunc

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?

Thanks!

Posted

Found the solution by tearing into some other scripts.

if I add this to my code:

Opt("GuiResizeMode", 802)

everything stays put

  • 4 years later...

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
  • Recently Browsing   0 members

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