Jump to content

MetroGUI UDF v5.1 - Windows 10 style buttons, toggles, radios, menu etc.


BBs19
 Share

Recommended Posts

16 hours ago, BBs19 said:

1. Yes this seems to be the case with all WS_POPUP windows. I haven't noticed this before. I will consider creating the non resizable GUI the same way like the the resizable one (preventing the borders from being drawn). However im not sure how this will impact compatibility, I still haven't tested my UDF on all Windows versions. The WS_POPUP version is more reliable than the borderless GUI version.

2. The GDIPlus functions work with ARGB colors. example: "0xFF000000". So the usual RGB hex colors of the Autoit functions don't work here anyways. I can add a workaround to make it work with hex colors, i just didn't see any need for it.

Understood, makes sense.

Now, can you please hint me how to modify the button creation function to add a picture? I tried but it simply can't draw the picture:

  

    ;Add frame
    _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor)


    ;Add Picture
    $hImage1   = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\win7.png")
    ; Draw PNG image
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND(GetCurrentGUI())
    _GDIPlus_GraphicsDrawImageRect($hGraphic,$hImage1,10,10,200,200)

    ;Release created objects
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($Brush_BTN_FontColor)
    _GDIPlus_BrushDispose($Brush_BTN_FontColorDis)
    _GDIPlus_PenDispose($Pen_BTN_FrameHoverColor)

 

Thanks!

Edited by KarlosTHG
Link to comment
Share on other sites

Is it possible to use your UDF in conjunction with GUIonEventMode 1?

Tryed to get it to work for several hours but sadly to no avail, didn't manage to get any functionality besides the mouseover/hover :(.
Is there something really obvious I'm missing? I did tons over tons of reading and simply can't find the reason its not working.

I would really appreciate it if you could take a short look at it to clarify for me if its possible or not.

gui.au3

Edited by Mentis
Link to comment
Share on other sites

On 6.7.2016 at 0:45 PM, RWBaker said:

Running Version: MetroUDF-V4.0.1 with Windows 10

The attached file defines and uses two radio groups.  Group 1 works fine, Group 2 does not work correctly.

Could you look into this?

Thanks,

RWBaker

Radio Demo.au3

Oh sh**t. Forgot to assign the radio group variable correctly while creating the radio. I will upload a fixed version with some other bug fixes this week. Thanks for reporting.

 

 

On 30.6.2016 at 4:18 PM, KarlosTHG said:

Understood, makes sense.

Now, can you please hint me how to modify the button creation function to add a picture? I tried but it simply can't draw the picture:

  

    ;Add frame
    _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor)


    ;Add Picture
    $hImage1   = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\win7.png")
    ; Draw PNG image
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND(GetCurrentGUI())
    _GDIPlus_GraphicsDrawImageRect($hGraphic,$hImage1,10,10,200,200)

    ;Release created objects
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($Brush_BTN_FontColor)
    _GDIPlus_BrushDispose($Brush_BTN_FontColorDis)
    _GDIPlus_PenDispose($Pen_BTN_FrameHoverColor)

 

Thanks!

I don't know it just by looking at it, i would need to check and test myself. I am really not experienced with GDI+. I have not much time atm. I will tell you later when when im working on the UDF.

 

 

16 hours ago, Mentis said:

Is it possible to use your UDF in conjunction with GUIonEventMode 1?

Tryed to get it to work for several hours but sadly to no avail, didn't manage to get any functionality besides the mouseover/hover :(.
Is there something really obvious I'm missing? I did tons over tons of reading and simply can't find the reason its not working.

I would really appreciate it if you could take a short look at it to clarify for me if its possible or not.

gui.au3

It works partly, but it isn't fully compatible with it. There will be some incompatibilities.

The reason you can't click any buttons is, because you used "GUICtrlSetOnEvent(-1,"_button")". -1 is AutoIt internal and works only with the last created control. In the UDF, the main Autoit control (GUICtrlCreatePic) is created at the beginning and is probably overwritten by something else before the function ends. I will try to move that to the end of the functions, as it seems to be a better option. 

But as I said, there will/might be problems with guictrlsetonevent as it will interfere with many other internal functions.

Link to comment
Share on other sites

Thanks for your quickly reply and really clear explanation what exactly went wrong.
 

Amazing UDF but sadly my software depends on GUIonEventMode 1, theres no realistic way to get arround that.
I'll definitely keep my eyes on your thread and wait, it would be definitely superawesome if you figured something out
My guis "only" requirements in order to establish a basic functionality are  metrobuttons that call a func(), metro Checkebox, metro messagebox, , GUICtrlSetData and GUICtrlSetOnEvent

I'd really love to help and extend your UDF myself, but sadly my skills are not sufficient :( (yet)

Link to comment
Share on other sites

On 8.7.2016 at 3:16 PM, PratikV said:

Hi BBs19, Thank you for the MetroUI. 

I am in the same boat as of Mentis and would like to know how can i use GUIOneventMode Function.

Thank you very much for the wonderful work.

Yes, give me a few days. I have already fixed many bugs and will try to add compatibility for GUIOnEventMode in the next step.

Link to comment
Share on other sites

7 hours ago, hawk63 said:

Thank you for this great UDF.

Just one question : haw can i change the text of the toggle when i click on it (like windows 10) ? In order to display 'enabled' / 'disabled'.

You couldn't do that before, but now you can, see new version :) 

 

On 8.7.2016 at 3:16 PM, PratikV said:

Hi BBs19, Thank you for the MetroUI. 

I am in the same boat as of Mentis and would like to know how can i use GUIOneventMode Function.

Thank you very much for the wonderful work.

Sorry dude, GUIOnEventMode just won't work fully with this UDF. This UDF is just too big.. There are just too many workarounds implemented to make everything work as it does at the moment.

I had it running almost, but the metro MsgBox and Menu just won't work that way. Anything that stops the script when waiting for user input breaks the compatibility for OnEvent.  I ran out of ideas for new workarounds...

You can use it with one GUI though, if you don't use metro MsgBox, Menu or a second GUI..

Edited by BBs19
Link to comment
Share on other sites

Version 4.3 - Changelog - 13.07.2016

Bugfixes:

  • Fixed a bug where the fullscreen button was misplaced on different DPI sizes.
  • Fixed a bug where the maximized window was not properly on the top edge after using the fullscreen mode.
  • Fixed a bug where the checkbox groups were not assigned properly.
  • Fixed the bug that using "-1" didn't point to the handle of the created metro control (buttons, checkboxes etc.)
  • Fixed a bug where the default window control buttons appeared after minimizing from the taskbar and using older Windows versions.
  • Fixed a bug where MustDeclareVars option couldn't be used without errors.
  • Fixed a bug that caused problems when using multiple metro GUIs with fullscreen + resizing option.

Improvements:

  • Dark themes are slightly brighter now. They were too dark on many screens.
  • Creating a GUI without drag&resize is now also created as a true borderless GUI instead of using $WS_POPUP. (To support minimizing from the taskbar)
  • When working with multiple metro GUIs, you no longer need to use "_GUI_DragAndResizeUpdate" after switching GUIs. (_GUI_DragAndResizeUpdate won't work anymore)
  • You can now pass color settings for the metro functions in hex and don't have to pass it as string.

New features:

  • Added on/off toggles. This allows you to create a toggle with two different texts like "enabled/disabled".
  • Added timeout option for metro MsgBox.
  • Added font options for the menu buttons.
  • Added new _Metro_SetGUIOption which allows to set options like drag, resize, min width and min height seperately for a GUI.

 

Download: 

 

Link to comment
Share on other sites

  • 3 weeks later...

I've been having a play about but i cant stop it from going full screen, can anyone help me?.

My script is:

#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /rm /pe
#AutoIt3Wrapper_Res_HiDpi=y
#TrayIcon
#include "MetroGUI-UDF\MetroGUI_UDF.au3"

_SetTheme("DarkBlueV2") ;See MetroThemes.au3 for selectable themes or to add more
_Metro_EnableHighDPIScaling()

$Form1 = _Metro_CreateGUI("Example", 350, 350, -1, -1)
$Control_Buttons = _Metro_AddControlButtons(True, False, False, False, True) ;CloseBtn = True, MaximizeBtn = True, MinimizeBtn = True, FullscreenBtn = True, MenuBtn = True

;Set variables for the handles of the GUI-Control buttons. (Above function always returns an array this size and in this order, no matter which buttons are selected.
$GUI_CLOSE_BUTTON = $Control_Buttons[0]
$GUI_MAXIMIZE_BUTTON = $Control_Buttons[1]
$GUI_RESTORE_BUTTON = $Control_Buttons[2]
$GUI_MINIMIZE_BUTTON = $Control_Buttons[3]
$GUI_FULLSCREEN_BUTTON = $Control_Buttons[4]
$GUI_FSRestore_BUTTON = $Control_Buttons[5]
$GUI_MENU_BUTTON = $Control_Buttons[6]
;======================================================================================================================================================================

;Create  Buttons
$Button1 = _Metro_CreateButton("Button Style 1", 105, 245, 130, 40)
$Button2 = _Metro_CreateButtonEx("Button Style 2", 255, 245, 130, 40)

;Create an Array containing menu button names
Dim $MenuButtonsArray[4] = ["a", "b", "", "Exit"]

GUISetState(@SW_SHOW)

While 1
    _Metro_HoverCheck_Loop($Form1) ;This hover check has to be added to the main While loop, otherwise the hover effects won't work.
    $nMsg = GUIGetMsg()
    Switch $nMsg
        ;=========================================Control-Buttons===========================================
        Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON
            _Metro_GUIDelete($Form1) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs!
            Exit
        Case $GUI_MAXIMIZE_BUTTON
            GUISetState(@SW_MAXIMIZE)
        Case $GUI_RESTORE_BUTTON
            GUISetState(@SW_RESTORE)
        Case $GUI_MINIMIZE_BUTTON
            GUISetState(@SW_MINIMIZE)
        Case $GUI_FULLSCREEN_BUTTON, $GUI_FSRestore_BUTTON
            _Metro_FullscreenToggle($Form1, $Control_Buttons)
            ;===================================================================================================
        Case $GUI_MENU_BUTTON
            Local $MenuSelect = _Metro_MenuStart($Form1, $GUI_MENU_BUTTON, 150, $MenuButtonsArray, "Segoe UI", 9, 0) ; Opens the metro Menu. See decleration of $MenuButtonsArray above.
            Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array.
                Case "0"
                    ConsoleWrite("Returned 0 = Settings button clicked." & @CRLF)
                Case "1"
                    ConsoleWrite("Returned 1 = About button clicked." & @CRLF)
                Case "2"
                    ConsoleWrite("Returned 2 = Contact button clicked." & @CRLF)
                Case "3"
                    ConsoleWrite("Returned 3 = Exit button clicked." & @CRLF)
                    _Metro_GUIDelete($Form1)
                    Exit
            EndSwitch
        Case $Button2
            _GUIDisable($Form1, 0, 30) ;For better visibility of the MsgBox on top of the first GUI.
            _Metro_MsgBox(0, "Metro MsgBox Example", "Button 2 clicked. (Button with 3 secs timeout)", 400, 11, $Form1, 3) ; with 3 secs timeout
            _GUIDisable($Form1)
        Case $Button1
            _GUIDisable($Form1, 0, 30)

            Local $Select_YesNo = _Metro_MsgBox(4, "Metro MsgBox Example", "Select yes to create a second GUI.", 350, 11, $Form1)
            If $Select_YesNo = "Yes" Then _SecondGUI()
            _GUIDisable($Form1)
    EndSwitch
WEnd


Func _SecondGUI()
    Local $Form2 = _Metro_CreateGUI("Example2", 600, 400, -1, -1, True)

    ;Add control buttons
    Local $Control_Buttons_2 = _Metro_AddControlButtons(True, True, True, True)

    ;Set variables for control buttons
    Local $GUI_CLOSE_BUTTON = $Control_Buttons_2[0]
    Local $GUI_MAXIMIZE_BUTTON = $Control_Buttons_2[1]
    Local $GUI_RESTORE_BUTTON = $Control_Buttons_2[2]
    Local $GUI_MINIMIZE_BUTTON = $Control_Buttons_2[3]
    Local $GUI_FULLSCREEN_BUTTON = $Control_Buttons_2[4]
    Local $GUI_FSRestore_BUTTON = $Control_Buttons_2[5]
    Local $Button1 = _Metro_CreateButton("Close", 250, 340, 100, 40)
    GUICtrlSetResizing($Button1, 768 + 8)
    GUISetState(@SW_SHOW)

    While 1
        _Metro_HoverCheck_Loop($Form2) ;Add hover check in loop
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON, $Button1
                _Metro_GUIDelete($Form2) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs!
                Return 0
            Case $GUI_MAXIMIZE_BUTTON
                GUISetState(@SW_MAXIMIZE)
            Case $GUI_RESTORE_BUTTON
                GUISetState(@SW_RESTORE)
            Case $GUI_MINIMIZE_BUTTON
                GUISetState(@SW_MINIMIZE)
            Case $GUI_FULLSCREEN_BUTTON, $GUI_FSRestore_BUTTON
                _Metro_FullscreenToggle($Form2, $Control_Buttons_2)
        EndSwitch
    WEnd
EndFunc   ;==>_SecondGUI

 

Link to comment
Share on other sites

Just found this a couple days ago, I really like it!

I have an example (heavily modified, though the display is close to the same, minus the progress bar and secondary window).

This example is a great way to solve the inability to use GUIOnEventMode, and a great way to add more constantly updating code (like Network games, etc) in the future.

This example has two scripts: Main.au3, and App.au3, where App.au3 is essentially the GUI code.

Main.au3 has Three functions that get called automagicly for convenience and conservation sake:

-OnStart(), which is invoked after the code is ready to roll

-OnUpdate($FrameTime), which is invoked $UPDATESPERSECOND (a global constant) * Second, and supplies the time between frames, incase you need time sensitive code to adjust for lost time.

-OnPreStop(), which is the function where you would put clean up code, all OnUpdate code is still valid in this function.

-DoStop(), which causes the program to request stop immediately, obviously.

App.au3 is the modified GUI code. Main.au3:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.2
 Author:         Jon/~RepComm

 Script Function:
    Main (Runs update clock, and exposes functions for application use)

#ce ----------------------------------------------------------------------------

#include "App.au3"

Opt ("MustDeclareVars", 1)

Global Const $UPDATESPERSECOND = 30
Global $STATE = False ; Set to False when exiting from this script (Normally we just check _App_GetState() from App.au3)

#Region =======Internal========
Init ()

Func Init() ; Called to initialize everything (Entry point)
    $STATE = True
    ;Global Const $UPDATESPERSECOND = 30
    Global Const $TimeBetweenUpdates = 1000 / $UPDATESPERSECOND ; 1000 Millis = 1 second
    Global $IsRunning = true
    Global $oTimer = TimerInit()
    Global $nNowTime = 0
    Global $nLastTime = 0
    Global $nUpdateTime ; In OnUpdate(), this value can be used to get time the last frame took
    Global $nNowThenDifference ; Every frame cycle, this equals now - last
    OnStart()
    CauseUpdates()
EndFunc

Func CauseUpdates () ; Called to start the clock-invoked OnUpdate function
    While ($IsRunning) ; Constantly loop
        $nNowTime = TimerDiff($oTimer) ; Get difference from program startup to now
        $nNowThenDifference = $nNowTime - $nLastTime ; Difference from last time we updated to now
        If ($nNowThenDifference >= $TimeBetweenUpdates) Then ; If sufficient time has passed, Update
            If (_App_GetState() == False Or $STATE == False) Then ; Check if App.au3's code wants to stop
                Stop() ; Cause program to stop completely
            EndIf
            $nLastTime = $nNowTime ; Future use of vars
            $nUpdateTime = $nNowThenDifference ; $nUpdateTime is always the amount of time it took between frames (Second/Updates), NowThenDiff can potentially be any time inbetween
            OnUpdate($nUpdateTime) ; Invoke Update function $UPDATESPERSECOND * Second, supplying the time we took between frames (Useful for physics or time relative calculations)
        EndIf
    WEnd
    ; This function ends when the program ends
EndFunc

Func Stop () ; Call to stop program
    OnPreStop() ; All OnUpdate code is still valid for use in this function (Until IsRunning = False)
    $IsRunning = False ; Stops OnUpdate() From happening
    Exit ; Final stop
EndFunc
#EndRegion

Func OnStart() ; Put initializing or startup code here
    ; Called after internal is already setup and ready to roll
    _App_Start() ; Tell App.au3's code to init its GUI 'n stuff
EndFunc

Func OnUpdate ($FrameTime) ; You can put constantly updating code here
    ; This function is called $UPDATESPERSECOND * Second
    ; $FrameTime is the time between this update, and the last one, in seconds. (Incase you have time-sensitive calculations to do)
    _App_Update($FrameTime) ; Update our GUI code in App.au3
EndFunc

Func OnPreStop () ; You can put cleanup code here
    ; This function is called before the program actually does any cleaning, so all update code is still valid here
    _App_Stop()
EndFunc

Func DoStop() ; Call this function to request app stop immediately
    $STATE = False
EndFunc

App.au3:

#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /rm /pe
#AutoIt3Wrapper_Res_HiDpi=y

#NoTrayIcon
#include "MetroGUI-UDF\MetroGUI_UDF.au3"

Global $STATE = False
Global $nMsg

Func _App_Start()
    $STATE = True
    _SetTheme("DarkAmber")
    _Metro_EnableHighDPIScaling()

    Global $hGUIMain = _Metro_CreateGUI("App", 720, 420, -1, -1, True)
    Global $Control_Buttons = _Metro_AddControlButtons(True, True, True, True, True) ;CloseBtn = True, MaximizeBtn = True, MinimizeBtn = True, FullscreenBtn = True, MenuBtn = True

    Global $GUI_CLOSE_BUTTON = $Control_Buttons[0]
    Global $GUI_MAXIMIZE_BUTTON = $Control_Buttons[1]
    Global $GUI_RESTORE_BUTTON = $Control_Buttons[2]
    Global $GUI_MINIMIZE_BUTTON = $Control_Buttons[3]
    Global $GUI_FULLSCREEN_BUTTON = $Control_Buttons[4]
    Global $GUI_FSRestore_BUTTON = $Control_Buttons[5]
    Global $GUI_MENU_BUTTON = $Control_Buttons[6]

    Global $Button1 = _Metro_CreateButton("Button Style 1", 105, 245, 130, 40)
    Global $Button2 = _Metro_CreateButtonEx("Button Style 2", 255, 245, 130, 40)

    Global $Checkbox1 = _Metro_CreateCheckbox("Checkbox 1", 30, 70, 125, 30)
    Global $Checkbox2 = _Metro_CreateCheckboxEx("Checkbox 2", 30, 107, 125, 30)
    _Metro_CheckboxCheck($Checkbox1)
    _Metro_CheckboxCheck($Checkbox2)

    Global $Radio1 = _Metro_CreateRadio("1", "Radio 1", 180, 70, 100, 30)
    Global $Radio2 = _Metro_CreateRadio("1", "Radio 2", 180, 110, 100, 30)
    _Metro_RadioCheck("1", $Radio1)

    Global $Toggle1 = _Metro_CreateToggle("Toggle 1", 320, 70, 130, 30)
    Global $Toggle2 = _Metro_CreateToggleEx("Toggle 2", 322, 107, 128, 30)
    Global $Toggle3 = _Metro_CreateOnOffToggle("Enabled", "Disabled", 320, 144, 130, 30)

    ;Create an Array containing menu button names
    Global $MenuButtonsArray[4] = ["Settings", "About", "Contact", "Exit"]

    GUICtrlSetResizing($Button1, 768 + 8)
    GUICtrlSetResizing($Button2, 768 + 8)
    GUICtrlSetResizing($Checkbox1, 768 + 2 + 32)
    GUICtrlSetResizing($Checkbox2, 768 + 2 + 32)
    GUICtrlSetResizing($Radio1, 768 + 2 + 32)
    GUICtrlSetResizing($Radio2, 768 + 2 + 32)
    GUICtrlSetResizing($Toggle1, 768 + 2 + 32)
    GUICtrlSetResizing($Toggle2, 768 + 2 + 32)
    GUICtrlSetResizing($Toggle3, 768 + 2 + 32)

    GUISetState(@SW_SHOW)
EndFunc

Func _App_Update ($FrameTime) ; Most of this code is staying the same, because _App_Update is in a constant loop (Main.au3's OnUpdate() function)
    _Metro_HoverCheck_Loop($hGUIMain) ;  This was moved from a bland while() statement
    $nMsg = GUIGetMsg()
    Switch $nMsg
        ;=========================================Control-Buttons===========================================
        Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON
            _Metro_GUIDelete($hGUIMain) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs!
            _App_Stop()
        Case $GUI_MAXIMIZE_BUTTON
            GUISetState(@SW_MAXIMIZE)
        Case $GUI_RESTORE_BUTTON
            GUISetState(@SW_RESTORE)
        Case $GUI_MINIMIZE_BUTTON
            GUISetState(@SW_MINIMIZE)
        Case $GUI_FULLSCREEN_BUTTON, $GUI_FSRestore_BUTTON
            _Metro_FullscreenToggle($hGUIMain, $Control_Buttons)
            ;===================================================================================================
        Case $GUI_MENU_BUTTON
            Local $MenuSelect = _Metro_MenuStart($hGUIMain, $GUI_MENU_BUTTON, 150, $MenuButtonsArray, "Segoe UI", 9, 0) ; Opens the metro Menu. See decleration of $MenuButtonsArray above.
            Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array.
                Case "0"
                    ConsoleWrite("Returned 0 = Settings button clicked." & @CRLF)
                Case "1"
                    ConsoleWrite("Returned 1 = About button clicked." & @CRLF)
                Case "2"
                    ConsoleWrite("Returned 2 = Contact button clicked." & @CRLF)
                Case "3"
                    ConsoleWrite("Returned 3 = Exit button clicked." & @CRLF)
                    _Metro_GUIDelete($hGUIMain) ; This can stay here, or be moved to a cleanup function (fired by Main.au3's OnPreStop() function)
                    _App_Stop()
            EndSwitch
        Case $Button2
            _GUIDisable($hGUIMain, 0, 30) ;For better visibility of the MsgBox on top of the first GUI.
            _Metro_MsgBox(0, "Metro MsgBox Example", "Button 2 clicked. (Button with 3 secs timeout)", 400, 11, $hGUIMain, 3) ; with 3 secs timeout
            _GUIDisable($hGUIMain)
        Case $Toggle1
            If _Metro_ToggleIsChecked($Toggle1) Then
                _Metro_ToggleUnCheck($Toggle1)
                ConsoleWrite("Toggle unchecked!" & @CRLF)
            Else
                _Metro_ToggleCheck($Toggle1)
                ConsoleWrite("Toggle checked!" & @CRLF)
            EndIf
        Case $Toggle2
            If _Metro_ToggleIsChecked($Toggle2) Then
                _Metro_ToggleUnCheck($Toggle2)
                ConsoleWrite("Toggle unchecked!" & @CRLF)
            Else
                _Metro_ToggleCheck($Toggle2)
                ConsoleWrite("Toggle checked!" & @CRLF)
            EndIf
        Case $Toggle3
            If _Metro_ToggleIsChecked($Toggle3) Then
                _Metro_ToggleUnCheck($Toggle3)
                ConsoleWrite("Disabled!" & @CRLF)
            Else
                _Metro_ToggleCheck($Toggle3)
                ConsoleWrite("Enabled!" & @CRLF)
            EndIf
        Case $Checkbox1
            If _Metro_CheckboxIsChecked($Checkbox1) Then
                _Metro_CheckboxUnCheck($Checkbox1)
                ConsoleWrite("Checkbox unchecked!" & @CRLF)
            Else
                _Metro_CheckboxCheck($Checkbox1)
                ConsoleWrite("Checkbox checked!" & @CRLF)
            EndIf
        Case $Checkbox2
            If _Metro_CheckboxIsChecked($Checkbox2) Then
                _Metro_CheckboxUnCheck($Checkbox2)
                ConsoleWrite("Checkbox unchecked!" & @CRLF)
            Else
                _Metro_CheckboxCheck($Checkbox2)
                ConsoleWrite("Checkbox checked!" & @CRLF)
            EndIf
        Case $Radio1
            _Metro_RadioCheck(1, $Radio1)
            ConsoleWrite("Radio 1 selected!" & @CRLF)
        Case $Radio2
            _Metro_RadioCheck(1, $Radio2)
            ConsoleWrite("Radio 2 selected = " & _Metro_RadioIsChecked(1, $Radio2) & @CRLF)
    EndSwitch
EndFunc

Func _App_Stop () ; Call this to tell Main.au3 to stop the program
    $STATE = False
EndFunc

Func _App_GetState () ; Main.au3 calls this in the update functions to see if we are still doing good
    Return $STATE
EndFunc

-- A side note, I was unable to change all the Theme for the window when using _SetTheme after initializations, etc. But the menu does change background color. A nice feature to look into (and I might just do this myself later), would be the ability to apply themes at runtime (since GDI plus doesn't care when you change brush colors, etc). You could just have a global variable that tells when SetTheme is used, and in the update loop, check it, and apply colors to the brushes that are used to draw the gui/controls, then draw them.

Edited by RepublicCommando
Spelling, no reason to double post, and I can't count..
Link to comment
Share on other sites

On 29.7.2016 at 7:33 PM, cookiemonster said:

I've been having a play about but i cant stop it from going full screen, can anyone help me?.

My script is:

 

 

On 29.7.2016 at 9:11 PM, nobbitry said:

Hi cookiemonster, 

its an error in the UDF. You can see it if you use:

$Control_Buttons = _Metro_AddControlButtons(True, True, True, True, True)

I didn't search for the error, but it only works if you set everything 'True'.

Regards

 

It is no bug. If you remove the creation of fullscreen button or other control buttons, then u also have to remove them from the switch case in the main while loop of the example :)

Link to comment
Share on other sites

my trouble resizing Progress

http://prntscr.com/c2jsc1

Spoiler
#include "MetroGUI-UDF\MetroGUI_UDF.au3"
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /rm /pe
#AutoIt3Wrapper_Res_HiDpi=y
_SetTheme("DarkBlue")
$Form1 = _Metro_CreateGUI("Example", 440, 500, -1, -1, True)
$Control_Buttons = _Metro_AddControlButtons(True, True, True, True, True) ;CloseBtn = True, MaximizeBtn = True, MinimizeBtn = True, FullscreenBtn = True, MenuBtn = True
$GUI_CLOSE_BUTTON = $Control_Buttons[0]
$GUI_MAXIMIZE_BUTTON = $Control_Buttons[1]
$GUI_RESTORE_BUTTON = $Control_Buttons[2]
$GUI_MINIMIZE_BUTTON = $Control_Buttons[3]
$GUI_FULLSCREEN_BUTTON = $Control_Buttons[4]
$GUI_FSRestore_BUTTON = $Control_Buttons[5]
$GUI_MENU_BUTTON = $Control_Buttons[6]

$Edit1 = GUICtrlCreateEdit("", 24, 82, 185, 217)
GUICtrlSetData(-1, "Edit1")
$Edit2 = GUICtrlCreateEdit("", 232, 82, 185, 217)
GUICtrlSetData(-1, "Edit2")
$Button1 = _Metro_CreateButton("Button 1", 72, 314, 91, 33)
$Button2 = _Metro_CreateButton("Button 2", 280, 314, 91, 33)

$Toggle1 = _Metro_CreateToggle("Alarm", 72, 355, 100, 30)
GUICtrlSetTip($Toggle1 , "On/Off")

$Checkbox1 = _Metro_CreateCheckbox("Check", 56, 32, 97, 30)
_Metro_CheckboxCheck($Checkbox1)
$Input1 = GUICtrlCreateInput("Input1", 24, 394, 393, 21)
$Progress1 = _Metro_CreateProgress(24, 434, 390, 33)
$Label1 = GUICtrlCreateLabel("Autoit", 296, 52, 64, 16)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)

Dim $MenuButtonsArray[4] = ["Settings", "About", "Contact", "Exit"]

GUICtrlSetResizing($Button1, 768 + 8)
GUICtrlSetResizing($Button2, 768 + 8)
GUICtrlSetResizing($Checkbox1, 768 + 2 + 32)
GUICtrlSetResizing($Progress1[0], 768 + 2 + 32)

GUISetState(@SW_SHOW)

While 1
    _Metro_HoverCheck_Loop($Form1)
    Sleep(10)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON
            _Metro_GUIDelete($Form1) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs!
            Exit
        Case $GUI_MAXIMIZE_BUTTON
            GUISetState(@SW_MAXIMIZE)
        Case $GUI_RESTORE_BUTTON
            GUISetState(@SW_RESTORE)
        Case $GUI_MINIMIZE_BUTTON
            GUISetState(@SW_MINIMIZE)
        Case $GUI_FULLSCREEN_BUTTON, $GUI_FSRestore_BUTTON
            _Metro_FullscreenToggle($Form1, $Control_Buttons)
    Case $GUI_MENU_BUTTON
            Local $MenuSelect = _Metro_MenuStart($Form1, $GUI_MENU_BUTTON, 150, $MenuButtonsArray, "Segoe UI", 9, 0) ; Opens the metro Menu. See decleration of $MenuButtonsArray above.
            Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array.
                Case "0"
                    ConsoleWrite("Returned 0 = Settings button clicked." & @CRLF)
                Case "1"
                    ConsoleWrite("Returned 1 = About button clicked." & @CRLF)
                Case "2"
                    ConsoleWrite("Returned 2 = Contact button clicked." & @CRLF)
                Case "3"
                    ConsoleWrite("Returned 3 = Exit button clicked." & @CRLF)
                    _Metro_GUIDelete($Form1)
                    Exit
            EndSwitch


        Case $Button1
            _Metro_MsgBox(0, "Metro MsgBox Example", "Button clicked.", 400, 11, $Form1)
For $i = 0 To 85 Step +2
                Sleep(5)
                _Metro_SetProgress($Progress1, $i)
Next

Case $Toggle1
            If _Metro_ToggleIsChecked($Toggle1) Then
                _Metro_ToggleUnCheck($Toggle1)
                ConsoleWrite("Toggle unchecked!" & @CRLF)
            Else
                _Metro_ToggleCheck($Toggle1)
                ConsoleWrite("Toggle checked!" & @CRLF)
            EndIf

            Case $Checkbox1
            If _Metro_CheckboxIsChecked($Checkbox1) Then
                _Metro_CheckboxUnCheck($Checkbox1)
                ConsoleWrite("Checkbox unchecked!" & @CRLF)
            Else
                _Metro_CheckboxCheck($Checkbox1)
                ConsoleWrite("Checkbox checked!" & @CRLF)
            EndIf

    EndSwitch
WEnd

 

 

Link to comment
Share on other sites

13 hours ago, youtuber said:

my trouble resizing Progress

http://prntscr.com/c2jsc1

  Hide contents
#include "MetroGUI-UDF\MetroGUI_UDF.au3"
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /rm /pe
#AutoIt3Wrapper_Res_HiDpi=y
_SetTheme("DarkBlue")
$Form1 = _Metro_CreateGUI("Example", 440, 500, -1, -1, True)
$Control_Buttons = _Metro_AddControlButtons(True, True, True, True, True) ;CloseBtn = True, MaximizeBtn = True, MinimizeBtn = True, FullscreenBtn = True, MenuBtn = True
$GUI_CLOSE_BUTTON = $Control_Buttons[0]
$GUI_MAXIMIZE_BUTTON = $Control_Buttons[1]
$GUI_RESTORE_BUTTON = $Control_Buttons[2]
$GUI_MINIMIZE_BUTTON = $Control_Buttons[3]
$GUI_FULLSCREEN_BUTTON = $Control_Buttons[4]
$GUI_FSRestore_BUTTON = $Control_Buttons[5]
$GUI_MENU_BUTTON = $Control_Buttons[6]

$Edit1 = GUICtrlCreateEdit("", 24, 82, 185, 217)
GUICtrlSetData(-1, "Edit1")
$Edit2 = GUICtrlCreateEdit("", 232, 82, 185, 217)
GUICtrlSetData(-1, "Edit2")
$Button1 = _Metro_CreateButton("Button 1", 72, 314, 91, 33)
$Button2 = _Metro_CreateButton("Button 2", 280, 314, 91, 33)

$Toggle1 = _Metro_CreateToggle("Alarm", 72, 355, 100, 30)
GUICtrlSetTip($Toggle1 , "On/Off")

$Checkbox1 = _Metro_CreateCheckbox("Check", 56, 32, 97, 30)
_Metro_CheckboxCheck($Checkbox1)
$Input1 = GUICtrlCreateInput("Input1", 24, 394, 393, 21)
$Progress1 = _Metro_CreateProgress(24, 434, 390, 33)
$Label1 = GUICtrlCreateLabel("Autoit", 296, 52, 64, 16)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)

Dim $MenuButtonsArray[4] = ["Settings", "About", "Contact", "Exit"]

GUICtrlSetResizing($Button1, 768 + 8)
GUICtrlSetResizing($Button2, 768 + 8)
GUICtrlSetResizing($Checkbox1, 768 + 2 + 32)
GUICtrlSetResizing($Progress1[0], 768 + 2 + 32)

GUISetState(@SW_SHOW)

While 1
    _Metro_HoverCheck_Loop($Form1)
    Sleep(10)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON
            _Metro_GUIDelete($Form1) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs!
            Exit
        Case $GUI_MAXIMIZE_BUTTON
            GUISetState(@SW_MAXIMIZE)
        Case $GUI_RESTORE_BUTTON
            GUISetState(@SW_RESTORE)
        Case $GUI_MINIMIZE_BUTTON
            GUISetState(@SW_MINIMIZE)
        Case $GUI_FULLSCREEN_BUTTON, $GUI_FSRestore_BUTTON
            _Metro_FullscreenToggle($Form1, $Control_Buttons)
    Case $GUI_MENU_BUTTON
            Local $MenuSelect = _Metro_MenuStart($Form1, $GUI_MENU_BUTTON, 150, $MenuButtonsArray, "Segoe UI", 9, 0) ; Opens the metro Menu. See decleration of $MenuButtonsArray above.
            Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array.
                Case "0"
                    ConsoleWrite("Returned 0 = Settings button clicked." & @CRLF)
                Case "1"
                    ConsoleWrite("Returned 1 = About button clicked." & @CRLF)
                Case "2"
                    ConsoleWrite("Returned 2 = Contact button clicked." & @CRLF)
                Case "3"
                    ConsoleWrite("Returned 3 = Exit button clicked." & @CRLF)
                    _Metro_GUIDelete($Form1)
                    Exit
            EndSwitch


        Case $Button1
            _Metro_MsgBox(0, "Metro MsgBox Example", "Button clicked.", 400, 11, $Form1)
For $i = 0 To 85 Step +2
                Sleep(5)
                _Metro_SetProgress($Progress1, $i)
Next

Case $Toggle1
            If _Metro_ToggleIsChecked($Toggle1) Then
                _Metro_ToggleUnCheck($Toggle1)
                ConsoleWrite("Toggle unchecked!" & @CRLF)
            Else
                _Metro_ToggleCheck($Toggle1)
                ConsoleWrite("Toggle checked!" & @CRLF)
            EndIf

            Case $Checkbox1
            If _Metro_CheckboxIsChecked($Checkbox1) Then
                _Metro_CheckboxUnCheck($Checkbox1)
                ConsoleWrite("Checkbox unchecked!" & @CRLF)
            Else
                _Metro_CheckboxCheck($Checkbox1)
                ConsoleWrite("Checkbox checked!" & @CRLF)
            EndIf

    EndSwitch
WEnd

 

 

Set the proper resizing option for the progress: 

GUICtrlSetResizing($Progress1[0],  1)

 

See https://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetResizing.htm

Link to comment
Share on other sites

  • 2 weeks later...

Hi,


I am using the MetroStyle-UDF, but i need a combo (pulldown) to fit in the style of the GUI.

I have attached my script to let you show what i mean, also you wil find an example of what i am looking for.
I am looking for a nice font to use in the GUI, can anyone give my a tip?

Hope you can help me.

Forum-Post.zip

Edited by Wingens
Link to comment
Share on other sites

  • 4 weeks later...
  • 4 weeks later...

Hi @KillTrot

I suggest to disable the Button and create a new one at that position (click Button 1 to change Button 2):

#NoTrayIcon
#include "MetroGUI-UDF\MetroGUI_UDF.au3"


_SetTheme("DarkGreen")
_Metro_EnableHighDPIScaling()

$Form1 = _Metro_CreateGUI("Example", 500, 300, -1, -1, False)
$Control_Buttons = _Metro_AddControlButtons(True)
$GUI_CLOSE_BUTTON = $Control_Buttons[0]

;Create  Buttons
$Button1 = _Metro_CreateButton("Button Style 1", 105, 245, 130, 40)
$Button2 = _Metro_CreateButtonEx("Button Style 2", 255, 245, 130, 40)

GUISetState(@SW_SHOW)

While 1
    _Metro_HoverCheck_Loop($Form1)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON
            _Metro_GUIDelete($Form1)
            Exit
        Case $Button1 ; <- That's what I mean
            $aPos = ControlGetPos($Form1, "", $Button2)
            _Metro_DisableButton($Button2)
            $Button2 = _Metro_CreateButton("New Button 2", $aPos[0], $aPos[1], $aPos[2], $aPos[3])
        Case $Button2
            MsgBox(0, "", "clicked", 1)
    EndSwitch
WEnd

 

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