Jump to content

fit control to desktop width height


Recommended Posts

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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