Jump to content

Positioning labels in full screen mode for various resolutions


Recommended Posts

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

Link to comment
Share on other sites

#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

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

Monkey's are, like, natures humans.

Link to comment
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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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