Jump to content

How do I make GUI are compatible with the computer screen size


ronaldo97
 Share

Recommended Posts

Hello :D
How can I make the GUI is  compatible with all screen sizes ?? :(

 

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 445, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZE))
GUISetBkColor(0x1E1E1E)
$Label1 = GUICtrlCreateLabel("Welcome Back !!", 424, 64, 161, 29)
GUICtrlSetFont(-1, 16, 400, 0, "Tahoma")
GUICtrlSetColor(-1, 0x800000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

    EndSwitch
WEnd
How do I make Gui interface compatible with all screen sizes ??

800*600

1024*768

1280*1024

Edited by ronaldo97
Link to comment
Share on other sites

  • Moderators

ronaldo97,

The @DeskTopWidth & @DeskTopHeight macros will give you the screen size - you then need to calculate what size and position you require for the GUI. Create the GUI at full size and use GUICtrlSetResizing on the controls (or use Opt("GUIResizeMode")) so that the controls will resize as well. Then resize and move the GUI like this:

; Set GUI to required position and size
 GUISetState(@SW_HIDE)
 WinMove($hGUI, "", $iMain_X, $iMain_Y, $iMain_W, $iMain_H)
 GUISetState(@SW_SHOW)

Please ask if you have any questions.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

5 hours ago, Melba23 said:

ronaldo97,

The @DeskTopWidth & @DeskTopHeight macros will give you the screen size - you then need to calculate what size and position you require for the GUI. Create the GUI at full size and use GUICtrlSetResizing on the controls (or use Opt("GUIResizeMode")) so that the controls will resize as well. Then resize and move the GUI like this:

; Set GUI to required position and size
 GUISetState(@SW_HIDE)
 WinMove($hGUI, "", $iMain_X, $iMain_Y, $iMain_W, $iMain_H)
 GUISetState(@SW_SHOW)

Please ask if you have any questions.

M23

Thank hou very much !!

 

Please explain to me possible video ??:'(

Edited by ronaldo97
Link to comment
Share on other sites

  • Moderators

ronaldo97,

Quote

Please explain to me possible video?

Why do you need a video? Just run this:

#include <GUIConstantsEx.au3>

; Get controls to resize with the GUI
Opt("GUIResizeMode", $GUI_DOCKAUTO)

; Get screen size
$iScreenWidth = @DesktopWidth
$iScreenHeight = @DesktopHeight

; Calculate required size and position
$iGUIX = 100
$iGUIY = 100
$iGUIWidth = $iScreenWidth - ($iGUIX * 2)
$iGUIHeight = $iScreenHeight - ($iGUIY * 2)

; Create GUI for assumed "normal" case
$hGUI = GUICreate("Test", 500, 500)

$cLabel = GUICtrlCreateLabel("This is the GUI at the size you created", 10, 10, 250, 50)
GUICtrlSetBkColor($clabel, 0xFFCCCC)

$cButton = GUICtrlCreateButton("Press me to resize the GUI", 10, 400, 150, 50)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cButton
            GUICtrlSetData($cLabel, "See how everything in the GUI" & @CRLF & "is resized along with the GUI?")
            ; Resize and relocate GUI as required
            WinMove($hGUI, "", $iGUIX, $iGUIY, $iGUIWidth, $iGUIHeight)
    EndSwitch

WEnd

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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

×
×
  • Create New...