Jump to content
gr1fter

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

Share this post


Link to post
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

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 2019-07-31 - Version 1.4.12.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
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

×
×
  • Create New...