Jump to content

How to create GUI that can scale size or fullscreen?


Recommended Posts

I've created many GUI based apps with Autoit, but I'd like to modify a GUI that I made that can resize (with all of its controls) or automatically display fullscreen based on the size of the display. If this is possible, what's the best approach?

Link to post
Share on other sites

I see NO effect from any setting of the Opt("GUIResizeMode",xxxx). How should it be used and what exactly does it do?

GUICtrlSetResizing(-1,1) does appear to work on the controls that I have tested so far EXCEPT that is has no effect on font size in labels and other controls. Can this be addressed?

Link to post
Share on other sites
On 12/2/2021 at 4:11 AM, wysocki said:

I've created many GUI based apps with Autoit, but I'd like to modify a GUI that I made that can resize (with all of its controls) or automatically display fullscreen based on the size of the display. If this is possible, what's the best approach?

i hope this help ya :)

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $gui
Global $newwidth
Example()
Func Example()
    Opt("GUICoordMode", 2)
$gui =  GUICreate("My InputBox", 190, 114, -1, -1, $WS_SIZEBOX + $WS_SYSMENU) ; start the definition
  Global $Width = WinGetClientSize($gui)[0]
  Global $Height = WinGetClientSize($gui)[1]
    GUISetFont(8, -1, "Arial")
    GUICtrlCreateLabel("Prompt", 8, 7) ; add prompt info
    GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP)

    Local $idButton_Edit = GUICtrlCreateInput("Default", -1, 3, 175, 20, $ES_PASSWORD) ; add the input area
    GUICtrlSetState($idButton_Edit, $GUI_FOCUS)
    GUICtrlSetResizing($idButton_Edit, $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)

  Global $idButton_OK = GUICtrlCreateButton("OK", -1, 3, 75, 24) ; add the button that will close the GUI
    GUICtrlSetResizing($idButton_OK, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE + $GUI_DOCKHCENTER)
Global $idButton_Cancel = GUICtrlCreateButton("Cancel", 25, -1) ; add the button that will close the GUI
    GUICtrlSetResizing($idButton_Cancel, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE + $GUI_DOCKHCENTER)

    GUISetState(@SW_SHOW) ; to display the GUI

    ; Loop until the user exits.
    While 1
      _ResizeFont()
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
 EndFunc   ;==>Example
 Func _ResizeFont()
    if   $Width  <> WinGetClientSize($gui)[0] Then
       ;;;;;;;here you can change size of font!!
        GUICtrlSetFont($idButton_OK,13,2,"Arial")
        GUICtrlSetFont($idButton_Cancel,13,2,"Arial")
        $newwidth = WinGetClientSize($gui)[0]
        $Width = $newwidth
     EndIf
     EndFunc

 

Edited by ad777
Link to post
Share on other sites

Thanks for the idea. Your code had a couple errors in it ($idButton_Cancel has to be global and the func name should be _Resize ). But after I got it running I see what you're doing. I'll have to think about how the font resizing should gradually proceed, relative to the height and width of the dialog. Ideally I'd like the dialog to appear as if it were an image to be stretched, horizontally and vertically. This can't be done when resizing fonts.

Link to post
Share on other sites
15 hours ago, wysocki said:

Thanks for the idea. Your code had a couple errors in it ($idButton_Cancel has to be global and the func name should be _Resize ). But after I got it running I see what you're doing. I'll have to think about how the font resizing should gradually proceed, relative to the height and width of the dialog. Ideally I'd like the dialog to appear as if it were an image to be stretched, horizontally and vertically. This can't be done when resizing fonts.

Maype this help ya:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>
Global $gui
Global $newwidth,$label12,$new4
Example()
Func Example()
    Opt("GUICoordMode", 2)
$gui =  GUICreate("My InputBox", 190, 114, -1, -1, $WS_SIZEBOX + $WS_SYSMENU) ; start the definition
  Global $Width = WinGetClientSize($gui)[0]
  Global $Height = WinGetClientSize($gui)[1]
    GUISetFont(8, -1, "Arial")
 $label12 =  GUICtrlCreateLabel("Prompt", 5, 7) ; add prompt info
    GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP)

    Local $idButton_Edit = GUICtrlCreateInput("Default", -1, 3, 175, 20, $ES_PASSWORD) ; add the input area
    GUICtrlSetState($idButton_Edit, $GUI_FOCUS)
    GUICtrlSetResizing($idButton_Edit, $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)

  Global $idButton_OK = GUICtrlCreateButton("OK", -1, 3, 75, 24) ; add the button that will close the GUI
    GUICtrlSetResizing($idButton_OK, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE + $GUI_DOCKHCENTER)
Global $idButton_Cancel = GUICtrlCreateButton("Cancel", 25, -1) ; add the button that will close the GUI
    GUICtrlSetResizing($idButton_Cancel, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE + $GUI_DOCKHCENTER)

    GUISetState(@SW_SHOW) ; to display the GUI

    ; Loop until the user exits.
    While 1
      _ResizeFont()
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
 EndFunc   ;==>Example
 Func _ResizeFont()

    if   $Width < WinGetClientSize($gui)[0] And $height <> WinGetClientSize($gui)[1]  Then
       ;;;;;;;here you can change size of font!!
       $new4 = $new4 + 8
        GUICtrlSetFont($label12 ,$new4,1,"Arial")

        $newwidth = WinGetClientSize($gui)[0]
        $Width = $newwidth
     EndIf
       if    $Width >  WinGetClientSize($gui)[0] And $height <> WinGetClientSize($gui)[1] Then
       ;;;;;;;here you can change size of font!!
       $new4 = $new4 - 5
        GUICtrlSetFont($label12 ,$new4,1,"Arial")
          $Width = WinGetClientSize($gui)[0]
     EndIf
     EndFunc

 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...