Jump to content
Sign in to follow this  
JellyFish666

fit control to desktop width height

Recommended Posts

JellyFish666

I am not sure how to do this my GUI is my desktop width and height and I want to have 4 objects take up all the room in the GUI equally.

I am not sure what I should divide by to make all 4 parts equal and I want it to work on all monitors widths and heights.

#include <GUIConstants.au3>
GUICreate("test", @DesktopWidth, @DesktopHeight)
GUICtrlCreateGraphic(0 , 0 , @DesktopWidth /? , @DesktopHeight /?)
GUICtrlCreateGraphic(? , ? , @DesktopWidth /? , @DesktopHeight /?)
GUICtrlCreateGraphic(? , ? , @DesktopWidth /? , @DesktopHeight /?)
GUICtrlCreateGraphic(? , ? , @DesktopWidth /? , @DesktopHeight /?)
GUISetState(@SW_SHOW)


While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
DaRam

You need to decide if you want them stacked side by side or tiled on your GUI.

Also are there margins between them?

For no gaps, side by side the height is the height of your GUI and the widths are your GUI's width / 4

For tile, each one will he height/4 and width / 4, position them thus: 0,0 | 0, width/4 | 0, height / 4 | width/4, height/4

Share this post


Link to post
Share on other sites
BrettF

So like divide the screen into 4 parts? I guess divide by 2... So the following.

#include <GUIConstants.au3>
GUICreate("test", @DesktopWidth, @DesktopHeight)

GUICtrlCreateGraphic(0 , 0 , @DesktopWidth /2, @DesktopHeight /2)
GUICtrlSetBkColor (-1, 0xF2289F)
GUICtrlCreateGraphic(0 ,  @DesktopHeight /2, @DesktopWidth /2, @DesktopHeight /2)
GUICtrlCreateGraphic(@DesktopWidth /2, 0, @DesktopWidth /2, @DesktopHeight /2)
GUICtrlCreateGraphic(@DesktopWidth /2, @DesktopHeight /2, @DesktopWidth /2, @DesktopHeight /2)
GUICtrlSetBkColor (-1, 0xF2289F)
GUISetState(@SW_SHOW)

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
flip209

Nicely done...


" I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln

Share this post


Link to post
Share on other sites
JellyFish666

Perfect, exactly what I was trying to do and now I can start coding :(

This project will be very interesting :)

Share this post


Link to post
Share on other sites
Skrip

You may need to minus like 110 from the height, because of the title bar.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites
DaRam

You may need to minus like 110 from the height, because of the title bar.

In VBA you had a properties of a window called InsideWidth and InsideHeight. :) I wonder if AutoIT GUI has some constants defined for use similar to these.

Share this post


Link to post
Share on other sites
therks

You can use WinGetClientSize on the window before creating the controls. Of course, if your window is fullscreen this isn't a problem, but don't know if that's what the OP wants.

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  

×