gr1fter

Positioning labels in full screen mode for various resolutions

5 posts in this topic

Hello, 

I have this test script and its driving me crazy.  I want to display a full screen GUI, but I can't get the labels to stay in position on different monitors.

Here is my test code:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$gui = GUICreate("Test GUI", @DesktopWidth, @DesktopHeight, 0, 0, BitOr($WS_CAPTION, $WS_SYSMENU, $WS_POPUP, $WS_MAXIMIZE))
GUISetState (@SW_LOCK)
GUISetBkColor(0xFFFFFF)

;Labels
$mainlabel_line1 = GUICtrlCreateLabel("This is a test,", @DesktopWidth/3-450, @DesktopHeight/2-250, 310, 35)
$mainlabel_line2 = GUICtrlCreateLabel("I want this label to stay in the same position on multiple resolutions",@DesktopWidth/3-450, @DesktopHeight/2-180, 675, 100)

$font = "Arial"

GUICtrlSetFont ($mainlabel_line1,22,1000,"",$font)
GUICtrlSetFont ($mainlabel_line2,22,1000,"",$font)


GUISetState(@SW_ENABLE)
GUISetState(@SW_SHOW)


While 1
        $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
        Exit
    EndSelect
WEnd

 

on the machine I am creating the script, it works great and shows correctly.  This is on 1920x1200 resolution.  When i go to a machine that is 1280x1024 and run the script, all the labels get messed up.  I posted screenshots of what it looks like. Is there anyway that I can have my labels set no matter what resolution I go to?

Thanks, 

 

 

1920x1200.PNG

1280x1024.PNG

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Left = 100

$gui = GUICreate("Test GUI", @DesktopWidth, @DesktopHeight, 0, 0, BitOr($WS_CAPTION, $WS_SYSMENU, $WS_POPUP, $WS_MAXIMIZE))
GUISetState (@SW_LOCK)
GUISetBkColor(0xFFFFFF)

;Labels
$mainlabel_line1 = GUICtrlCreateLabel("This is a test,", $Left, @DesktopHeight/2-250, 310, 35)
$mainlabel_line2 = GUICtrlCreateLabel("I want this label to stay in the same position on multiple resolutions",$Left, @DesktopHeight/2-180, 675, 100)

$font = "Arial"

GUICtrlSetFont ($mainlabel_line1,22,1000,"",$font)
GUICtrlSetFont ($mainlabel_line2,22,1000,"",$font)


GUISetState(@SW_ENABLE)
GUISetState(@SW_SHOW)


While 1
        $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
        Exit
    EndSelect
WEnd

EDIT:

Or maybe you mean something like...

$Left = Mod(@DesktopWidth / 4, @DesktopWidth)

Edited by JohnOne
1 person likes this

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

setting a static Left worked! man i thought way too much into it and it was something simple.  Thank you!

Share this post


Link to post
Share on other sites

Or use GUICtrlSetResizing to specify the resizing method used by a control. Example:

GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKRIGHT + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)

Sets the resizing method for the last control to dock at the top and right and to keep widht and height.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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