Jump to content

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


BBs19
 Share

Recommended Posts

I know I disappointed some of you guys with this version as you were waiting for the requested features like Sliders, InputBox, Support for tabbing through controls and other stuff. I spent a lot of time for other improvements and got tired of trying to find ways to get stuff to work:) 

I tried adding many other things like fully transparent controls, but ended up building in so many workarounds and it still didn't fully work as I wanted to.. I know there are examples for sliders etc. but it gets too complicated and too time consuming when trying to build it into the UDF for easy usage. 

These are the things on my ToDo List at the moment but I can't tell if or when I will built them in.

  • Windows 10 Style Sliders (Like the volume slider)
  • Some sort of modern looking tab/menu.
  • Simple Inputbox (low prio)
  • Support for tabbing through controls

Maybe someone is interested in helping out :P

Link to comment
Share on other sites

Also, I realise you use GuiGetMsg with you while loops in your UDF.

I generally use Event mode so on the While loops you have I have edited it slightly to include

Local $PreviousOpt = Opt("GUIOnEventMode")

Opt("GUIOnEventMode", 0)

then just before the return I set it back to the original mode which in my case is event mode.

is there anything I'm missing that my changes could mess with in your UDF?

Link to comment
Share on other sites

2 minutes ago, joboy2k said:

Also, I realise you use GuiGetMsg with you while loops in your UDF.

I generally use Event mode so on the While loops you have I have edited it slightly to include

Local $PreviousOpt = Opt("GUIOnEventMode")

Opt("GUIOnEventMode", 0)

then just before the return I set it back to the original mode which in my case is event mode.

is there anything I'm missing that my changes could mess with in your UDF?

OnEventMode is officially not supported in this UDF. However with this version most of the features should work just fine.

MsgBox, Menu and the Right-Click Menu are using while loops and might not work therefore. And now that you say it, I know what else was on my ToDo list :P

Link to comment
Share on other sites

Also, not sure what the issue is or whether I need to change something in my side of the script but when I switch tabs with V5 UDF included instead of the older version nothing displays in the tab until I drag my mouse around and controls start appearing when I move over them, as soon as I put the old UDF it goes back to working seamlessly. If needed I can post a replicant script or screenshots (or links to them) to show what I mean if its not clear.

I had time and cut it down, GUI2 is what is supposed to be displayed on tabs. it did work perfectly with the older version of MetroGUI UDF

#include-once
#include <MetroGUI_UDF.au3>
#include <ListViewConstants.au3>
Gui() ; Using Metro GUI creation
sleep(1000)
Gui2() ; Using standard GUI creation
While 1
    Sleep(100)
WEnd
Func Gui()
    $GUI = _Metro_CreateGUI("Sendean", 1197, 677, (@DesktopWidth / 2) - (1197 / 2), (@DesktopHeight / 2) - (677 /2))
    GUISetFont(12, 0, 0, "Segoe UI")
    GUICtrlCreateTab(197, 79, 989, 574)
    GUICtrlCreateTabItem("Search")
    GUICtrlCreateListView("a|a|a|a|a|a|a", 200, 109, 981, 540, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_SORTDESCENDING, $WS_BORDER), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) ;
    GUICtrlCreateTabItem("Data Entry")
    GUICtrlCreateListView("b|b|b|b|b|b|b", 200, 109, 981, 540, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_SORTDESCENDING, $WS_BORDER), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) ;
    GUISetState(@SW_SHOW)
EndFunc


Func GUI2()
    $GUI = GUICreate("Sendean", 1197, 677, (@DesktopWidth / 2) - (1197 / 2), (@DesktopHeight / 2) - (677 /2))
    GUISetFont(12, 0, 0, "Segoe UI")
    GUICtrlCreateTab(197, 79, 989, 574)
    GUICtrlCreateTabItem("Search")
    GUICtrlCreateListView("a|a|a|a|a|a|a", 200, 109, 981, 540, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_SORTDESCENDING, $WS_BORDER), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) ;
    GUICtrlCreateTabItem("Data Entry")
    GUICtrlCreateListView("b|b|b|b|b|b|b", 200, 109, 981, 540, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_SORTDESCENDING, $WS_BORDER), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) ;
    GUISetState(@SW_SHOW)
EndFunc

 

Edited by joboy2k
Link to comment
Share on other sites

On 5/23/2017 at 6:27 PM, BBs19 said:

Much appreciate the updates you are able to implement. Really great GUI as is.

Appreciated that you included: If you prefer handling the buttons manually, then you can disable this by setting "$ControlBtnsAutoMode = False"

As I didn't want to rewrite too much while using your new UDF. However, what about other commands and coding (like calling fullscreen with the wrong number of paramaters and a few others)?

Is there an easy way to "convert" code that was based on the previous UDF to be easily compatible with your new UDF?  Just hoping, thanks!

Link to comment
Share on other sites

On 5.9.2017 at 6:38 PM, joboy2k said:

Also, not sure what the issue is or whether I need to change something in my side of the script but when I switch tabs with V5 UDF included instead of the older version nothing displays in the tab until I drag my mouse around and controls start appearing when I move over them, as soon as I put the old UDF it goes back to working seamlessly. If needed I can post a replicant script or screenshots (or links to them) to show what I mean if its not clear.

I had time and cut it down, GUI2 is what is supposed to be displayed on tabs. it did work perfectly with the older version of MetroGUI UDF

#include-once
#include <MetroGUI_UDF.au3>
#include <ListViewConstants.au3>
Gui() ; Using Metro GUI creation
sleep(1000)
Gui2() ; Using standard GUI creation
While 1
    Sleep(100)
WEnd
Func Gui()
    $GUI = _Metro_CreateGUI("Sendean", 1197, 677, (@DesktopWidth / 2) - (1197 / 2), (@DesktopHeight / 2) - (677 /2))
    GUISetFont(12, 0, 0, "Segoe UI")
    GUICtrlCreateTab(197, 79, 989, 574)
    GUICtrlCreateTabItem("Search")
    GUICtrlCreateListView("a|a|a|a|a|a|a", 200, 109, 981, 540, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_SORTDESCENDING, $WS_BORDER), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) ;
    GUICtrlCreateTabItem("Data Entry")
    GUICtrlCreateListView("b|b|b|b|b|b|b", 200, 109, 981, 540, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_SORTDESCENDING, $WS_BORDER), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) ;
    GUISetState(@SW_SHOW)
EndFunc


Func GUI2()
    $GUI = GUICreate("Sendean", 1197, 677, (@DesktopWidth / 2) - (1197 / 2), (@DesktopHeight / 2) - (677 /2))
    GUISetFont(12, 0, 0, "Segoe UI")
    GUICtrlCreateTab(197, 79, 989, 574)
    GUICtrlCreateTabItem("Search")
    GUICtrlCreateListView("a|a|a|a|a|a|a", 200, 109, 981, 540, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_SORTDESCENDING, $WS_BORDER), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) ;
    GUICtrlCreateTabItem("Data Entry")
    GUICtrlCreateListView("b|b|b|b|b|b|b", 200, 109, 981, 540, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_SORTDESCENDING, $WS_BORDER), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) ;
    GUISetState(@SW_SHOW)
EndFunc

 

Hmm I am afraid it is caused by _WinAPI_DefSubclassProc. Seems like a bug caused by the function or I am doing something wrong. Even the example has this problem when you add your tabs + listview: https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_DefSubclassProc.htm

There is currently no alternative for it other than fully restoring the UDF back to the old version which will cause the script to be less user friendly and not allow custom GUIRegisterMsg as the UDF needs them for handling basic stuff. Let me ask in forum if someone know why it is caused.

 

On 8.9.2017 at 4:59 PM, coffeeturtle said:

Much appreciate the updates you are able to implement. Really great GUI as is.

Appreciated that you included: If you prefer handling the buttons manually, then you can disable this by setting "$ControlBtnsAutoMode = False"

As I didn't want to rewrite too much while using your new UDF. However, what about other commands and coding (like calling fullscreen with the wrong number of paramaters and a few others)?

Is there an easy way to "convert" code that was based on the previous UDF to be easily compatible with your new UDF?  Just hoping, thanks!

There shouldn't be much changed. The fullscreen function works now with only one parameter (Gui handle), so you only have to remove the second parameter. Not sure if I changed more in other functions.

Link to comment
Share on other sites

  • 2 weeks later...

how can I change the theme color scheme instantly?

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include "MetroGUI-UDF\MetroGUI_UDF.au3"
#include <Array.au3>
Global $aAraayList[18] = ["LightTeal", "DarkTeal", "DarkMidnight", "DarkBlue", "DarkBlueV2", "LightCyan", "DarkCyan", "LightGray", "LightGreen", "DarkGreen", "LightRed", "DarkGray", "DarkAmber", "LightOrange", "DarkOrange", "LightPurple", "DarkPurple", "LightPink"]
Global $List = 0

_SetTheme(_ThemeChange())

$Form1 = _Metro_CreateGUI("Form1", 428, 258, -1, -1, True)
$Control_Buttons = _Metro_AddControlButtons(True, True, True, True, 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]

$ButtonSetTheme = _Metro_CreateButton("ButtonSet", 80, 160, 75, 25)
$ButtonChangeTheme = _Metro_CreateButton("ButtonChange", 240, 160, 75, 25)

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)
            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 $ButtonSetTheme
_ThemeChange()
    EndSwitch
WEnd

Func _ThemeChange()
            If $List >= UBound($aAraayList) Then $List = 0
;~             ConsoleWrite($aAraayList[$List] & @CRLF)
RegWrite('HKCU\Software\MetroGui\Tema', 'Set','REG_SZ', $aAraayList[$List])
Local $VarTema = RegRead('HKCU\Software\MetroGui\Tema', 'Set')
$List += 1
Return $VarTema
EndFunc

 

Link to comment
Share on other sites

something like this

message_2.jpg

but this is build on old fashion mode

and has 1 pixel border with other color than backcolor

which bother me .

I don't know how to remove completely the border

or color the border in same color like backcolor

any ideas ?

c

Edited by oneLess
Link to comment
Share on other sites

The only way to remove the border is adding a Label to the same position as the button using the default AutoIt method.

$Button1 = GUICtrlCreateButton("Button1", 16, 24, 203, 41 )
GUICtrlSetBkColor($Button1,0xffffff)
GuiCtrlSetColor($Button1, 0x333333)

 

Kind Regards
Skeletor

"Coffee: my defense against going postal."

Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI

Link to comment
Share on other sites

  • 2 weeks later...
Quote

Version 5.0.0.1 - Changelog - 07.10.2017

Bugfixes:

  • Fixed a bug where certain things in the GUI (Tabs/Listviews) were not handled properly because of a bug in _WinAPI_DefSubclassProc. Thanks @LarsJ.
  • Removed the automated handling of the control buttons (except for fullscreen), as they were triggering the close/min/max/restore message multiple times when the user clicked them on the child window multiple times during a sleep, which caused the parent window to also receive the message.
  • Fixed a bug where in certain situations the active child window prevented the fullscreen activation from working properly on the parent window.
  • Fixed a bug where the resize cursor was not displayed properly when hovering over the corners. -> Currently it is required to reset the cursor to default if you use any controls very close to the window border and move your mouse from the corner to the control. I will try to think of something later. 
  • Fixed a bug where the lines of the _Metro_AddControlButton_Back were misplaced on certain DPI settings. Also fixed the hover not working with this button.
  • Other small changes

New features:

  •  Added _Metro_AddHSeperator/_Metro_AddVSeperator to create simple vertical/horizontal seperator lines in the GUI.

Download: 

 

 

Link to comment
Share on other sites

On 19.9.2017 at 11:19 PM, youtuber said:

how can I change the theme color scheme instantly?

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include "MetroGUI-UDF\MetroGUI_UDF.au3"
#include <Array.au3>
Global $aAraayList[18] = ["LightTeal", "DarkTeal", "DarkMidnight", "DarkBlue", "DarkBlueV2", "LightCyan", "DarkCyan", "LightGray", "LightGreen", "DarkGreen", "LightRed", "DarkGray", "DarkAmber", "LightOrange", "DarkOrange", "LightPurple", "DarkPurple", "LightPink"]
Global $List = 0

_SetTheme(_ThemeChange())

$Form1 = _Metro_CreateGUI("Form1", 428, 258, -1, -1, True)
$Control_Buttons = _Metro_AddControlButtons(True, True, True, True, 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]

$ButtonSetTheme = _Metro_CreateButton("ButtonSet", 80, 160, 75, 25)
$ButtonChangeTheme = _Metro_CreateButton("ButtonChange", 240, 160, 75, 25)

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)
            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 $ButtonSetTheme
_ThemeChange()
    EndSwitch
WEnd

Func _ThemeChange()
            If $List >= UBound($aAraayList) Then $List = 0
;~             ConsoleWrite($aAraayList[$List] & @CRLF)
RegWrite('HKCU\Software\MetroGui\Tema', 'Set','REG_SZ', $aAraayList[$List])
Local $VarTema = RegRead('HKCU\Software\MetroGui\Tema', 'Set')
$List += 1
Return $VarTema
EndFunc

 

Doesn't work instantly because the metro controls are just pictures, they can't be changed without recreating them. You can either restart the program or you can delete the old controls and recreate them after setting the new theme. As for the background of the GUI, you can update it using GUISetBkColor($GUIThemeColor, $Form1) after changing the theme.

Link to comment
Share on other sites

  • 2 weeks later...

Hey! Nice update! but...

I'm having some troubles using these new UDF with multiple forms because sometimes when i try to close the script it crashes!

This is my function to close the program, it closes all the gui's oppened:

Func ProgramClose()
    _Metro_GUIDelete($form_Main) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs!
    _Metro_GUIDelete($form_Notas) 
    _Metro_GUIDelete($form_Calendario)

    If $form_Pictogramas <> -1 Then _Metro_GUIDelete($form_Pictogramas)
    If $form_Parametros <> -1 Then _Metro_GUIDelete($form_Parametros)
    If $form_Calculos <> -1 Then _Metro_GUIDelete($form_Calculos)
    If $form_TabelaPeriodica <> -1 Then _Metro_GUIDelete($form_TabelaPeriodica)
    If $form_Calendario <> -1 Then _Metro_GUIDelete($form_Calendario)
    If $form_Notas <> -1 Then _Metro_GUIDelete($form_Notas)
    If $form_Config <> -1 Then _Metro_GUIDelete($form_Config)

    Exit 0
EndFunc   ;==>ProgramClose

I was wondering if it would be possible to create a function that closes all the parameters and functions used by MetroUDF avoiding all theses crashes problems!

Thx!

Link to comment
Share on other sites

On 16.10.2017 at 7:01 PM, x_bennY said:

Hey! Nice update! but...

I'm having some troubles using these new UDF with multiple forms because sometimes when i try to close the script it crashes!

This is my function to close the program, it closes all the gui's oppened:

Func ProgramClose()
    _Metro_GUIDelete($form_Main) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs!
    _Metro_GUIDelete($form_Notas) 
    _Metro_GUIDelete($form_Calendario)

    If $form_Pictogramas <> -1 Then _Metro_GUIDelete($form_Pictogramas)
    If $form_Parametros <> -1 Then _Metro_GUIDelete($form_Parametros)
    If $form_Calculos <> -1 Then _Metro_GUIDelete($form_Calculos)
    If $form_TabelaPeriodica <> -1 Then _Metro_GUIDelete($form_TabelaPeriodica)
    If $form_Calendario <> -1 Then _Metro_GUIDelete($form_Calendario)
    If $form_Notas <> -1 Then _Metro_GUIDelete($form_Notas)
    If $form_Config <> -1 Then _Metro_GUIDelete($form_Config)

    Exit 0
EndFunc   ;==>ProgramClose

I was wondering if it would be possible to create a function that closes all the parameters and functions used by MetroUDF avoiding all theses crashes problems!

Thx!

Hi, You can just use "Exit" if you want to close the program, all resources will be released when exiting, there is a OnExit registered by the UDF, _Metro_GUIDelete is only required if you want to close a specific GUI while working with multiple GUIs.

 

 

Quote

Version 5.1 - Changelog - 17.10.2017

New features:

  • Added support for OnEventMode - The UDF will automatically detect this if you enable OnEventMode before including the MetroUDF. You can also manually enable it using _Metro_EnableOnEventMode.
  • Added _Metro_InputBox - A modern looking input box that allows entering a PW or other details.
  • Added a new parameter "$tMargin" to _Metro_AddControlButtons and _Metro_AddControlButton_Back, to allow custom margin size (free space from the corners)
  • Added _Metro_ToggleSwitch, _Metro_CheckboxSwitch, toggles between checked/unchecked states and then return the current state.  -> Should only be used to handle user clicks
  • Added GUIAccelerator to _Metro_MsgBox to allow closing the MsgBox faster by pressing enter to click the default button.

Improvments:

  • Aligned the toggle/radio text to the left instead of center
  • Increased hover effect visibilty on the Metro Toggle when using a light theme.

Bugfixes:

  • Added a workaround for the resize cursor getting stuck on controls very close to the window border. 
  • Fixed hover effect of toggle checked being stuck despite the $NoAnimation parameter being set to true for startup.
  • Added a new parameter "$NoHoverEffect" to _Metro_RadioCheck and _Metro_CheckboxCheck to prevent the hover effect from appearing/freezing when calling the function manually without user interaction. 
    • Should be used anytime the checkbox/radio is not "clicked" by the user but checked manually during startup otherwise the hover effect is stuck until the mouse is moved over the control

New version released. The v5 update created quite some bugs. Slowly fixing all bugs I find while using the UDF in another project and also adding some new things that should have been there in the first place, like _Metro_ToggleSwitch and _Metro_CheckboxSwitch:)

> Also added support for the OnEventMode, see included example on how to use.

 

Ps.: You can simply edit things like font, buttonstyle etc. for functions like _Metro_MsgBox in the main UDF. I prefer not to add 100 parameters for every function to allow 100% customization. 

Edited by BBs19
Link to comment
Share on other sites

Hi,

Give you some solution for tab control from me.

 

flat.png

 

FlatTab.au3

#include-once
#include <GDIPlus.au3>
#include <Array.au3>
#include "GUICtrlOnHover.au3"

Global $FlatUIColor = DllStructCreate("struct;float back;float fore;float frame;endstruct;")
$FlatUIColor.back = 0x3C4649
$FlatUIColor.fore = 0x23A86D ;0x3498db
$FlatUIColor.frame = 0x2D2F31

Global Const $tObjTabEx = "hwnd hwnd;byte ctrl;byte ctab;" & _
                        "byte count;byte current;int next;" & _
                        "int width;int x;int y;"
Global Const $tObjTabBtnEx = "byte ctrl;byte ctab;byte idtab;" & _
                        "wchar text[255];"
Global $____aTabList[1] = [0]
Global $____aTabBtnList[1] = [0]

Func FlatTab_Create($hWnd, $Left, $Top, $Width, $Height)
    GUISwitch($hWnd)

    Local $oObj = DllStructCreate($tObjTabEx)
    _ArrayAdd($____aTabList, $oObj)
    $____aTabList[0] += 1
    $oObj.hwnd = $hWnd

    $oObj.ctrl = GUICtrlCreatePic("", $Left, $Top+25, $Width, $Height-50)
    GUICtrlSetResizing($oObj.ctrl, 802)
    GUICtrlSetState($oObj.ctrl, 128)
    $oObj.ctab = GUICtrlCreateTab(-99, -99, 1, 1)
    GUICtrlSetState($oObj.ctab, 128)

    Local $aBmp = _GDIPlus_BitmapCreateFromScan0($Width, $Height-50)
    Local $hGfx = _GDIPlus_ImageGetGraphicsContext($aBmp)
    Local $hPen = _GDIPlus_PenCreate($FlatUIColor.frame+0xFF000000, 4)
    Local $hBrush = _GDIPlus_BrushCreateSolid($FlatUIColor.frame+0xFF000000)
    _GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $Width, $Height-50, $hPen)
    _GDIPlus_GraphicsFillRect($hGfx, 0, 0, $Width, $Height-50, $hBrush)
    _GDIPlus_GraphicsClear($hGfx, $FlatUIColor.frame+0xFF000000)
    Local $hBmp = _GDIPlus_BitmapCreateDIBFromBitmap($aBmp)
    _GDIPlus_BitmapDispose($aBmp)
    _GDIPlus_GraphicsDispose($hGfx)
    _GDIPlus_PenDispose($hPen)
    _WinAPI_DeleteObject(GUICtrlSendMsg($oObj.ctrl, 0x0172, 0, $hBmp))
    _WinAPI_DeleteObject($hBmp)

    $oObj.width = $Width
    $oObj.x = $Left
    $oObj.y = $Top
    $oObj.current = ""
    $oObj.count = 0
    $oObj.next = $Left

    Return $oObj
EndFunc

Func FlatTab_AddTab($Ctrl, $Text)
    GUISwitch($Ctrl.hwnd)
    GUICtrlCreateTabItem("")

    Local $oObj = DllStructCreate($tObjTabBtnEx)
    _ArrayAdd($____aTabBtnList, $oObj)
    $____aTabBtnList[0] += 1
    $oObj.ctrl = GUICtrlCreatePic("", $Ctrl.next, $Ctrl.y, 80, 25)
    GUICtrlSetResizing($oObj.ctrl, 802)
    _GUICtrl_OnHoverRegister($oObj.ctrl, 'FlatTab_EventHover', 'FlatTab_EventHover', 'FlatTab_EventClick', 'FlatTab_EventClick')
    $oObj.count +=1
    $oObj.idtab = GUICtrlCreateTabItem($oObj.count)
    $oObj.text = $Text

    If $Ctrl.current <> "" Then
        Local $Prev = FlatTab_GetObjTabBtnFromCtrl($Ctrl.current)
        FlatTab_Draw($Prev.ctrl, $Prev.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF000000)
    EndIf
    FlatTab_Draw($oObj.ctrl, $Text, 0xFFFFFFFF, $FlatUIColor.frame+0xFF000000)

    $Ctrl.current = $oObj.ctrl
    $oObj.ctab = $Ctrl.ctab
    $Ctrl.next += 80
    GUICtrlSetState($oObj.idtab, 16)
    Return $oObj.idtab
EndFunc

Func FlatTab_EventHover($Ctrl, $Mode)
    Local $Obj1 = FlatTab_GetObjTabFromCtrl($Ctrl)
    If $Obj1.current = $Ctrl Then Return
    Local $Obj2 = FlatTab_GetObjTabBtnFromCtrl($Ctrl)
    Switch $Mode
        Case 1
            FlatTab_Draw($Ctrl, $Obj2.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF151515)
        Case 2
            FlatTab_Draw($Ctrl, $Obj2.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF000000)
    EndSwitch
EndFunc

Func FlatTab_EventClick($Ctrl, $Mode)
    If $Mode = 2 Then
        Local $Obj1 = FlatTab_GetObjTabFromCtrl($Ctrl)
        If $Obj1.current = $Ctrl Then Return
        Local $Obj2 = FlatTab_GetObjTabBtnFromCtrl($Ctrl)
        Local $Obj3 = FlatTab_GetObjTabBtnFromCtrl($Obj1.current)
        FlatTab_Draw($Ctrl, $Obj2.text, 0xFFFFFFFF, $FlatUIColor.frame+0xFF000000)
        FlatTab_Draw($Obj3.ctrl, $Obj3.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF000000)
        GUICtrlSetState($Obj2.idtab, 16)
        $Obj1.current = $Ctrl
    EndIf
EndFunc

Func FlatTab_GetObjTabFromCtrl($Ctrl)
    Local $Obj2, $Index
    Local $Obj = FlatTab_GetObjTabBtnFromCtrl($Ctrl)

    If $____aTabList[0] = 0 Then Return False

    For $Index = $____aTabList[0] To 1 Step -1
        $Obj2 = $____aTabList[$Index]
        If $Obj2.ctab == $Obj.ctab Then Return $____aTabList[$Index]
    Next

    Return False
EndFunc

Func FlatTab_GetObjTabBtnFromCtrl($Ctrl)
    Local $Obj, $Index

    If $____aTabBtnList[0] = 0 Then Return False
    For $Index = $____aTabBtnList[0] To 1 Step -1
        $Obj = $____aTabBtnList[$Index]
        If $Obj.ctrl == $Ctrl Then Return $____aTabBtnList[$Index]
    Next

    Return False
EndFunc

Func FlatTab_Draw($iCtrl, $Text, $Color = 0xFFFFFFFF, $BgColor = 0x00FFFFFF)
    Local $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iCtrl))
    Local $aPos = ControlGetPos($hWnd, "", $iCtrl)
    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate("Segoe UI Semibold")
    Local $hFont =  _GDIPlus_FontCreate($hFamily, 10, 0)
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, $aPos[2], $aPos[3])
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    _GDIPlus_StringFormatSetLineAlign($hFormat, 1)
    Local $aBitmaps = _GDIPlus_BitmapCreateFromScan0($aPos[2], $aPos[3])
    Local $aGfxCtxt = _GDIPlus_ImageGetGraphicsContext($aBitmaps)
    _GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt, 2)
    _GDIPlus_GraphicsSetTextRenderingHint($aGfxCtxt, 5)
    _GDIPlus_GraphicsClear($aGfxCtxt, $BgColor)
    Local $hBrushColor = _GDIPlus_BrushCreateSolid($Color)
    _GDIPlus_GraphicsDrawStringEx($aGfxCtxt, $Text, $hFont, $tLayout, $hFormat, $hBrushColor)
    Local $aHBitmaps = _GDIPlus_BitmapCreateDIBFromBitmap($aBitmaps)
    _GDIPlus_BrushDispose($hBrushColor)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_BitmapDispose($aBitmaps)
    _GDIPlus_GraphicsDispose($aGfxCtxt)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _WinAPI_DeleteObject(GUICtrlSendMsg($iCtrl, 0x0172, 0, $aHBitmaps))
    _WinAPI_DeleteObject($aHBitmaps)
EndFunc

 

FlatTab_Example.au3

#include "FlatTabEx.au3"
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

_GDIPlus_Startup();

Global $hGUI = GUICreate("FlatTab Example", 450, 290);
GUISetBkColor(0x3C4649, $hGUI);
GUISetFont(10, 400, 0, "Segoe UI", $hGUI, 5);


Global $Tab = FlatTab_Create($hGUI, 10, 10, 430, 290);
;=================================================
FlatTab_AddTab($Tab, "Tab 1");
GUICtrlCreateLabel("This is Tab 1", 30, 50);
GUICtrlSetColor(-1, 0xFFFFFF);
GUICtrlCreateButton("Button 1", 30, 100, 75, 25);
GUICtrlCreateButton("Button 2", 120, 100, 75, 25);
;=================================================
FlatTab_AddTab($Tab, "Tab 2");
GUICtrlCreateLabel("This is Tab 2", 30, 50);
GUICtrlSetColor(-1, 0xFFFFFF);
GUICtrlCreateButton("Button 3", 210, 100, 75, 25);
GUICtrlCreateButton("Button 4", 30, 150, 75, 25);
;=================================================
FlatTab_AddTab($Tab, "Tab 3");
GUICtrlCreateLabel("This is Tab 3", 30, 50);
GUICtrlSetColor(-1, 0xFFFFFF);
GUICtrlCreateButton("Button 5", 120, 150, 75, 25);
GUICtrlCreateButton("Button 6", 210, 150, 75, 25);
;=================================================
GUICtrlCreateTabItem("");

GUISetState();

Do
    Sleep(10);
Until GUIGetMsg() = -3;

 

Link to comment
Share on other sites

On 18.10.2017 at 4:16 PM, NHD said:

Hi,

Give you some solution for tab control from me.

 

flat.png

 

FlatTab.au3

#include-once
#include <GDIPlus.au3>
#include <Array.au3>
#include "GUICtrlOnHover.au3"

Global $FlatUIColor = DllStructCreate("struct;float back;float fore;float frame;endstruct;")
$FlatUIColor.back = 0x3C4649
$FlatUIColor.fore = 0x23A86D ;0x3498db
$FlatUIColor.frame = 0x2D2F31

Global Const $tObjTabEx = "hwnd hwnd;byte ctrl;byte ctab;" & _
                        "byte count;byte current;int next;" & _
                        "int width;int x;int y;"
Global Const $tObjTabBtnEx = "byte ctrl;byte ctab;byte idtab;" & _
                        "wchar text[255];"
Global $____aTabList[1] = [0]
Global $____aTabBtnList[1] = [0]

Func FlatTab_Create($hWnd, $Left, $Top, $Width, $Height)
    GUISwitch($hWnd)

    Local $oObj = DllStructCreate($tObjTabEx)
    _ArrayAdd($____aTabList, $oObj)
    $____aTabList[0] += 1
    $oObj.hwnd = $hWnd

    $oObj.ctrl = GUICtrlCreatePic("", $Left, $Top+25, $Width, $Height-50)
    GUICtrlSetResizing($oObj.ctrl, 802)
    GUICtrlSetState($oObj.ctrl, 128)
    $oObj.ctab = GUICtrlCreateTab(-99, -99, 1, 1)
    GUICtrlSetState($oObj.ctab, 128)

    Local $aBmp = _GDIPlus_BitmapCreateFromScan0($Width, $Height-50)
    Local $hGfx = _GDIPlus_ImageGetGraphicsContext($aBmp)
    Local $hPen = _GDIPlus_PenCreate($FlatUIColor.frame+0xFF000000, 4)
    Local $hBrush = _GDIPlus_BrushCreateSolid($FlatUIColor.frame+0xFF000000)
    _GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $Width, $Height-50, $hPen)
    _GDIPlus_GraphicsFillRect($hGfx, 0, 0, $Width, $Height-50, $hBrush)
    _GDIPlus_GraphicsClear($hGfx, $FlatUIColor.frame+0xFF000000)
    Local $hBmp = _GDIPlus_BitmapCreateDIBFromBitmap($aBmp)
    _GDIPlus_BitmapDispose($aBmp)
    _GDIPlus_GraphicsDispose($hGfx)
    _GDIPlus_PenDispose($hPen)
    _WinAPI_DeleteObject(GUICtrlSendMsg($oObj.ctrl, 0x0172, 0, $hBmp))
    _WinAPI_DeleteObject($hBmp)

    $oObj.width = $Width
    $oObj.x = $Left
    $oObj.y = $Top
    $oObj.current = ""
    $oObj.count = 0
    $oObj.next = $Left

    Return $oObj
EndFunc

Func FlatTab_AddTab($Ctrl, $Text)
    GUISwitch($Ctrl.hwnd)
    GUICtrlCreateTabItem("")

    Local $oObj = DllStructCreate($tObjTabBtnEx)
    _ArrayAdd($____aTabBtnList, $oObj)
    $____aTabBtnList[0] += 1
    $oObj.ctrl = GUICtrlCreatePic("", $Ctrl.next, $Ctrl.y, 80, 25)
    GUICtrlSetResizing($oObj.ctrl, 802)
    _GUICtrl_OnHoverRegister($oObj.ctrl, 'FlatTab_EventHover', 'FlatTab_EventHover', 'FlatTab_EventClick', 'FlatTab_EventClick')
    $oObj.count +=1
    $oObj.idtab = GUICtrlCreateTabItem($oObj.count)
    $oObj.text = $Text

    If $Ctrl.current <> "" Then
        Local $Prev = FlatTab_GetObjTabBtnFromCtrl($Ctrl.current)
        FlatTab_Draw($Prev.ctrl, $Prev.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF000000)
    EndIf
    FlatTab_Draw($oObj.ctrl, $Text, 0xFFFFFFFF, $FlatUIColor.frame+0xFF000000)

    $Ctrl.current = $oObj.ctrl
    $oObj.ctab = $Ctrl.ctab
    $Ctrl.next += 80
    GUICtrlSetState($oObj.idtab, 16)
    Return $oObj.idtab
EndFunc

Func FlatTab_EventHover($Ctrl, $Mode)
    Local $Obj1 = FlatTab_GetObjTabFromCtrl($Ctrl)
    If $Obj1.current = $Ctrl Then Return
    Local $Obj2 = FlatTab_GetObjTabBtnFromCtrl($Ctrl)
    Switch $Mode
        Case 1
            FlatTab_Draw($Ctrl, $Obj2.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF151515)
        Case 2
            FlatTab_Draw($Ctrl, $Obj2.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF000000)
    EndSwitch
EndFunc

Func FlatTab_EventClick($Ctrl, $Mode)
    If $Mode = 2 Then
        Local $Obj1 = FlatTab_GetObjTabFromCtrl($Ctrl)
        If $Obj1.current = $Ctrl Then Return
        Local $Obj2 = FlatTab_GetObjTabBtnFromCtrl($Ctrl)
        Local $Obj3 = FlatTab_GetObjTabBtnFromCtrl($Obj1.current)
        FlatTab_Draw($Ctrl, $Obj2.text, 0xFFFFFFFF, $FlatUIColor.frame+0xFF000000)
        FlatTab_Draw($Obj3.ctrl, $Obj3.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF000000)
        GUICtrlSetState($Obj2.idtab, 16)
        $Obj1.current = $Ctrl
    EndIf
EndFunc

Func FlatTab_GetObjTabFromCtrl($Ctrl)
    Local $Obj2, $Index
    Local $Obj = FlatTab_GetObjTabBtnFromCtrl($Ctrl)

    If $____aTabList[0] = 0 Then Return False

    For $Index = $____aTabList[0] To 1 Step -1
        $Obj2 = $____aTabList[$Index]
        If $Obj2.ctab == $Obj.ctab Then Return $____aTabList[$Index]
    Next

    Return False
EndFunc

Func FlatTab_GetObjTabBtnFromCtrl($Ctrl)
    Local $Obj, $Index

    If $____aTabBtnList[0] = 0 Then Return False
    For $Index = $____aTabBtnList[0] To 1 Step -1
        $Obj = $____aTabBtnList[$Index]
        If $Obj.ctrl == $Ctrl Then Return $____aTabBtnList[$Index]
    Next

    Return False
EndFunc

Func FlatTab_Draw($iCtrl, $Text, $Color = 0xFFFFFFFF, $BgColor = 0x00FFFFFF)
    Local $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iCtrl))
    Local $aPos = ControlGetPos($hWnd, "", $iCtrl)
    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate("Segoe UI Semibold")
    Local $hFont =  _GDIPlus_FontCreate($hFamily, 10, 0)
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, $aPos[2], $aPos[3])
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    _GDIPlus_StringFormatSetLineAlign($hFormat, 1)
    Local $aBitmaps = _GDIPlus_BitmapCreateFromScan0($aPos[2], $aPos[3])
    Local $aGfxCtxt = _GDIPlus_ImageGetGraphicsContext($aBitmaps)
    _GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt, 2)
    _GDIPlus_GraphicsSetTextRenderingHint($aGfxCtxt, 5)
    _GDIPlus_GraphicsClear($aGfxCtxt, $BgColor)
    Local $hBrushColor = _GDIPlus_BrushCreateSolid($Color)
    _GDIPlus_GraphicsDrawStringEx($aGfxCtxt, $Text, $hFont, $tLayout, $hFormat, $hBrushColor)
    Local $aHBitmaps = _GDIPlus_BitmapCreateDIBFromBitmap($aBitmaps)
    _GDIPlus_BrushDispose($hBrushColor)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_BitmapDispose($aBitmaps)
    _GDIPlus_GraphicsDispose($aGfxCtxt)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _WinAPI_DeleteObject(GUICtrlSendMsg($iCtrl, 0x0172, 0, $aHBitmaps))
    _WinAPI_DeleteObject($aHBitmaps)
EndFunc

 

FlatTab_Example.au3

#include "FlatTabEx.au3"
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

_GDIPlus_Startup();

Global $hGUI = GUICreate("FlatTab Example", 450, 290);
GUISetBkColor(0x3C4649, $hGUI);
GUISetFont(10, 400, 0, "Segoe UI", $hGUI, 5);


Global $Tab = FlatTab_Create($hGUI, 10, 10, 430, 290);
;=================================================
FlatTab_AddTab($Tab, "Tab 1");
GUICtrlCreateLabel("This is Tab 1", 30, 50);
GUICtrlSetColor(-1, 0xFFFFFF);
GUICtrlCreateButton("Button 1", 30, 100, 75, 25);
GUICtrlCreateButton("Button 2", 120, 100, 75, 25);
;=================================================
FlatTab_AddTab($Tab, "Tab 2");
GUICtrlCreateLabel("This is Tab 2", 30, 50);
GUICtrlSetColor(-1, 0xFFFFFF);
GUICtrlCreateButton("Button 3", 210, 100, 75, 25);
GUICtrlCreateButton("Button 4", 30, 150, 75, 25);
;=================================================
FlatTab_AddTab($Tab, "Tab 3");
GUICtrlCreateLabel("This is Tab 3", 30, 50);
GUICtrlSetColor(-1, 0xFFFFFF);
GUICtrlCreateButton("Button 5", 120, 150, 75, 25);
GUICtrlCreateButton("Button 6", 210, 150, 75, 25);
;=================================================
GUICtrlCreateTabItem("");

GUISetState();

Do
    Sleep(10);
Until GUIGetMsg() = -3;

 

Wow, that looks really nice, great work!

I will check out the code and try to build it in with the next version. 

Keep em coming if you have more custom controls :)

Link to comment
Share on other sites

On 17/10/2017 at 5:12 PM, BBs19 said:

Hi, You can just use "Exit" if you want to close the program, all resources will be released when exiting, there is a OnExit registered by the UDF, _Metro_GUIDelete is only required if you want to close a specific GUI while working with multiple GUIs.

 

 

New version released. The v5 update created quite some bugs. Slowly fixing all bugs I find while using the UDF in another project and also adding some new things that should have been there in the first place, like _Metro_ToggleSwitch and _Metro_CheckboxSwitch:)

> Also added support for the OnEventMode, see included example on how to use.

 

Ps.: You can simply edit things like font, buttonstyle etc. for functions like _Metro_MsgBox in the main UDF. I prefer not to add 100 parameters for every function to allow 100% customization. 

 

I got it... but i tryied in my script and it didn't work, it might be because i'm using an a "OnExit registered" , could i use both at the same time? or should i use only one with all the functions from the Metro UDF?

Thx for your answer!

Edited by x_bennY
Link to comment
Share on other sites

On 20.10.2017 at 1:45 AM, x_bennY said:

 

I got it... but i tryied in my script and it didn't work, it might be because i'm using an a "OnExit registered" , could i use both at the same time? or should i use only one with all the functions from the Metro UDF?

Thx for your answer!

Hi,

I tested it again and it is a bug in the internal exit function which starts deleting the GUIs from 0 to x instead of from x to 0.

Please replace the following function with the one from the MetroGUI_UDF.au3

Func _iMExit()
    For $i_HR = UBound($iGUI_LIST) - 1 To 0 Step -1
        _Metro_GUIDelete($iGUI_LIST[$i_HR][0])
    Next
    DllCallbackFree($m_hDll)
    _GDIPlus_Shutdown()
EndFunc   ;==>_iMExit

I will update the UDF later :)

Link to comment
Share on other sites

16 hours ago, BBs19 said:

Hi,

I tested it again and it is a bug in the internal exit function which starts deleting the GUIs from 0 to x instead of from x to 0.

Please replace the following function with the one from the MetroGUI_UDF.au3

Func _iMExit()
    For $i_HR = UBound($iGUI_LIST) - 1 To 0 Step -1
        _Metro_GUIDelete($iGUI_LIST[$i_HR][0])
    Next
    DllCallbackFree($m_hDll)
    _GDIPlus_Shutdown()
EndFunc   ;==>_iMExit

I will update the UDF later :)

Nice! thx! another question... is it possible to use more than one "OnAutoItExitRegisterOnAutoItExitRegister" in the same script?

And i'm trying to change the name of the button with the guictrlsetdata but it's not working, i took a look at the script and i don't think it's possible now, any ideas for the future? or to solve this?

Edited by x_bennY
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...