commit f6962624066082a5ac6eed98feee09d595b23a00 Author: tyleo Date: Sun Feb 18 22:17:39 2024 +0100 first commit diff --git a/ADB-FB-GUI/ADBGui.au3 b/ADB-FB-GUI/ADBGui.au3 new file mode 100755 index 0000000..e69de29 diff --git a/ADB-FB-GUI/FastBootGui.au3 b/ADB-FB-GUI/FastBootGui.au3 new file mode 100755 index 0000000..e69de29 diff --git a/ADB-FB-GUI/MainMenu.au3 b/ADB-FB-GUI/MainMenu.au3 new file mode 100755 index 0000000..e69de29 diff --git a/ADB-FB-GUI/exec/adb/AdbWinApi.dll b/ADB-FB-GUI/exec/adb/AdbWinApi.dll new file mode 100755 index 0000000..b5586eb Binary files /dev/null and b/ADB-FB-GUI/exec/adb/AdbWinApi.dll differ diff --git a/ADB-FB-GUI/exec/adb/AdbWinUsbApi.dll b/ADB-FB-GUI/exec/adb/AdbWinUsbApi.dll new file mode 100755 index 0000000..0c9e00b Binary files /dev/null and b/ADB-FB-GUI/exec/adb/AdbWinUsbApi.dll differ diff --git a/ADB-FB-GUI/exec/adb/adb.exe b/ADB-FB-GUI/exec/adb/adb.exe new file mode 100755 index 0000000..e6e0bc7 Binary files /dev/null and b/ADB-FB-GUI/exec/adb/adb.exe differ diff --git a/ADB-FB-GUI/exec/adb/fastboot.exe b/ADB-FB-GUI/exec/adb/fastboot.exe new file mode 100755 index 0000000..a3c68a1 Binary files /dev/null and b/ADB-FB-GUI/exec/adb/fastboot.exe differ diff --git a/ADB-FB-GUI/exec/driver/DPInst_x64.exe b/ADB-FB-GUI/exec/driver/DPInst_x64.exe new file mode 100755 index 0000000..3182f98 Binary files /dev/null and b/ADB-FB-GUI/exec/driver/DPInst_x64.exe differ diff --git a/ADB-FB-GUI/exec/driver/DPInst_x86.exe b/ADB-FB-GUI/exec/driver/DPInst_x86.exe new file mode 100755 index 0000000..a8d6099 Binary files /dev/null and b/ADB-FB-GUI/exec/driver/DPInst_x86.exe differ diff --git a/ADB-FB-GUI/exec/driver/amd64/NOTICE.txt b/ADB-FB-GUI/exec/driver/amd64/NOTICE.txt new file mode 100755 index 0000000..6cfa57a --- /dev/null +++ b/ADB-FB-GUI/exec/driver/amd64/NOTICE.txt @@ -0,0 +1,4 @@ +The .dll files here are distributed by Microsoft Corporation as part of the +Windows Driver Kit (available at +http://www.microsoft.com/whdc/resources/downloads.mspx) and included here as +permitted by the Microsoft Software License Terms. \ No newline at end of file diff --git a/ADB-FB-GUI/exec/driver/amd64/WUDFUpdate_01009.dll b/ADB-FB-GUI/exec/driver/amd64/WUDFUpdate_01009.dll new file mode 100755 index 0000000..1424634 Binary files /dev/null and b/ADB-FB-GUI/exec/driver/amd64/WUDFUpdate_01009.dll differ diff --git a/ADB-FB-GUI/exec/driver/amd64/WdfCoInstaller01009.dll b/ADB-FB-GUI/exec/driver/amd64/WdfCoInstaller01009.dll new file mode 100755 index 0000000..1731b96 Binary files /dev/null and b/ADB-FB-GUI/exec/driver/amd64/WdfCoInstaller01009.dll differ diff --git a/ADB-FB-GUI/exec/driver/amd64/winusbcoinstaller2.dll b/ADB-FB-GUI/exec/driver/amd64/winusbcoinstaller2.dll new file mode 100755 index 0000000..30e5502 Binary files /dev/null and b/ADB-FB-GUI/exec/driver/amd64/winusbcoinstaller2.dll differ diff --git a/ADB-FB-GUI/exec/driver/android_winusb.inf b/ADB-FB-GUI/exec/driver/android_winusb.inf new file mode 100755 index 0000000..f863993 --- /dev/null +++ b/ADB-FB-GUI/exec/driver/android_winusb.inf @@ -0,0 +1,169 @@ +; +; Android WinUsb driver installation. +; +[Version] +Signature = "$Windows NT$" +Class = AndroidUsbDeviceClass +ClassGuid = {3F966BD9-FA04-4ec5-991C-D326973B5128} +Provider = %ProviderName% +DriverVer = 08/28/2014,11.0.0000.00000 +CatalogFile.NTx86 = androidwinusb86.cat +CatalogFile.NTamd64 = androidwinusba64.cat + +[ClassInstall32] +Addreg = AndroidWinUsbClassReg + +[AndroidWinUsbClassReg] +HKR,,,0,%ClassName% +HKR,,Icon,,-1 + + +[Manufacturer] +%ProviderName% = Google, NTx86, NTamd64 + + +[Google.NTx86] + +;Google Nexus One +%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_0D02 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_0D02&MI_01 +%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_4E11 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E12&MI_01 + +;Google Nexus S +%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_4E21 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E22&MI_01 +%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_4E23 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E24&MI_01 + +;Google Nexus 7 +%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_4E40 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E42&MI_01 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E44&MI_01 + +;Google Nexus Q +%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_2C10 +%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_2C11 + +;Google Nexus (generic) +%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_4EE0 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4EE2&MI_01 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4EE4&MI_02 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4EE6&MI_01 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4EE7 + +;Google Glass +%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_9001 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_9001&MI_01 + +;Project Tango (generic) +%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_4D00 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4D02&MI_01 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4D04&MI_02 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4D06&MI_01 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4D07 + + +[Google.NTamd64] + +;Google Nexus One +%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_0D02 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_0D02&MI_01 +%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_4E11 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E12&MI_01 + +;Google Nexus S +%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_4E21 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E22&MI_01 +%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_4E23 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E24&MI_01 + +;Google Nexus 7 +%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_4E40 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E42&MI_01 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E44&MI_01 + +;Google Nexus Q +%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_2C10 +%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_2C11 + +;Google Nexus (generic) +%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_4EE0 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4EE2&MI_01 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4EE4&MI_02 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4EE6&MI_01 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4EE7 + +;Google Glass +%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_9001 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_9001&MI_01 + +;Project Tango (generic) +%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_4D00 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4D02&MI_01 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4D04&MI_02 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4D06&MI_01 +%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4D07 + + +[USB_Install] +Include = winusb.inf +Needs = WINUSB.NT + +[USB_Install.Services] +Include = winusb.inf +AddService = WinUSB,0x00000002,WinUSB_ServiceInstall + +[WinUSB_ServiceInstall] +DisplayName = %WinUSB_SvcDesc% +ServiceType = 1 +StartType = 3 +ErrorControl = 1 +ServiceBinary = %12%\WinUSB.sys + +[USB_Install.Wdf] +KmdfService = WINUSB, WinUSB_Install + +[WinUSB_Install] +KmdfLibraryVersion = 1.9 + +[USB_Install.HW] +AddReg = Dev_AddReg + +[Dev_AddReg] +HKR,,DeviceInterfaceGUIDs,0x10000,"{F72FE0D4-CBCB-407d-8814-9ED673D0DD6B}" + +[USB_Install.CoInstallers] +AddReg = CoInstallers_AddReg +CopyFiles = CoInstallers_CopyFiles + +[CoInstallers_AddReg] +HKR,,CoInstallers32,0x00010000,"WdfCoInstaller01009.dll,WdfCoInstaller","WinUSBCoInstaller2.dll" + +[CoInstallers_CopyFiles] +WinUSBCoInstaller2.dll +WdfCoInstaller01009.dll + +[DestinationDirs] +CoInstallers_CopyFiles=11 + +[SourceDisksNames] +1 = %DISK_NAME%,,,\i386 +2 = %DISK_NAME%,,,\amd64 + +[SourceDisksFiles.x86] +WinUSBCoInstaller2.dll = 1 +WdfCoInstaller01009.dll = 1 + +[SourceDisksFiles.amd64] +WinUSBCoInstaller2.dll = 2 +WdfCoInstaller01009.dll = 2 + +[Strings] +ProviderName = "Google, Inc." +SingleAdbInterface = "Android ADB Interface" +CompositeAdbInterface = "Android Composite ADB Interface" +SingleBootLoaderInterface = "Android Bootloader Interface" +WinUSB_SvcDesc = "Android USB Driver" +DISK_NAME = "Android WinUsb installation disk" +ClassName = "Android Device" diff --git a/ADB-FB-GUI/exec/driver/androidwinusb86.cat b/ADB-FB-GUI/exec/driver/androidwinusb86.cat new file mode 100755 index 0000000..2ad58b1 Binary files /dev/null and b/ADB-FB-GUI/exec/driver/androidwinusb86.cat differ diff --git a/ADB-FB-GUI/exec/driver/androidwinusba64.cat b/ADB-FB-GUI/exec/driver/androidwinusba64.cat new file mode 100755 index 0000000..1c1dc34 Binary files /dev/null and b/ADB-FB-GUI/exec/driver/androidwinusba64.cat differ diff --git a/ADB-FB-GUI/exec/driver/i386/NOTICE.txt b/ADB-FB-GUI/exec/driver/i386/NOTICE.txt new file mode 100755 index 0000000..6cfa57a --- /dev/null +++ b/ADB-FB-GUI/exec/driver/i386/NOTICE.txt @@ -0,0 +1,4 @@ +The .dll files here are distributed by Microsoft Corporation as part of the +Windows Driver Kit (available at +http://www.microsoft.com/whdc/resources/downloads.mspx) and included here as +permitted by the Microsoft Software License Terms. \ No newline at end of file diff --git a/ADB-FB-GUI/exec/driver/i386/WUDFUpdate_01009.dll b/ADB-FB-GUI/exec/driver/i386/WUDFUpdate_01009.dll new file mode 100755 index 0000000..f19c370 Binary files /dev/null and b/ADB-FB-GUI/exec/driver/i386/WUDFUpdate_01009.dll differ diff --git a/ADB-FB-GUI/exec/driver/i386/WdfCoInstaller01009.dll b/ADB-FB-GUI/exec/driver/i386/WdfCoInstaller01009.dll new file mode 100755 index 0000000..30e81af Binary files /dev/null and b/ADB-FB-GUI/exec/driver/i386/WdfCoInstaller01009.dll differ diff --git a/ADB-FB-GUI/exec/driver/i386/winusbcoinstaller2.dll b/ADB-FB-GUI/exec/driver/i386/winusbcoinstaller2.dll new file mode 100755 index 0000000..fc450d2 Binary files /dev/null and b/ADB-FB-GUI/exec/driver/i386/winusbcoinstaller2.dll differ diff --git a/ADB-FB-GUI/exec/install.bat b/ADB-FB-GUI/exec/install.bat new file mode 100755 index 0000000..81330cd --- /dev/null +++ b/ADB-FB-GUI/exec/install.bat @@ -0,0 +1,118 @@ +@ECHO off +CLS +TITLE 15 seconds ADB Installer v1.4.3 +COLOR 17 +ECHO ############################################################################### +ECHO # # +ECHO # 15 seconds ADB Installer # +ECHO # # +ECHO # version 1.4.3 # +ECHO # # +ECHO # by Snoop05 - Snoop05B@gmail.com # +ECHO # # +ECHO # Android Debug Bridge version 1.0.32 (MM) # +ECHO # Google USB Driver version 11.0.0000.00000 # +ECHO # # +ECHO # http://forum.xda-developers.com/showthread.php?t=2588979 # +ECHO # # +ECHO ############################################################################### +:Q1 +ECHO( +SET /P ANSWER=Do you want to install ADB and Fastboot? (Y/N) + IF /i {%ANSWER%}=={y} (GOTO Q2) + IF /i {%ANSWER%}=={yes} (GOTO Q2) + IF /i {%ANSWER%}=={n} (GOTO DRV) + IF /i {%ANSWER%}=={no} (GOTO DRV) +ECHO( +ECHO Bad answer! Use only Y/N or Yes/No +GOTO Q1 +:Q2 +ECHO( +SET /P ANSWER=Install ADB system-wide? (Y/N) + IF /i {%ANSWER%}=={y} (GOTO ADB_S) + IF /i {%ANSWER%}=={yes} (GOTO ADB_S) + IF /i {%ANSWER%}=={n} (GOTO ADB_U) + IF /i {%ANSWER%}=={no} (GOTO ADB_U) +ECHO( +ECHO Bad answer! Use only Y/N or Yes/No +GOTO Q2 +:ADB_U +ECHO( +ECHO Installing ADB and Fastboot ... (current user only) +ECHO( +ADB kill-server > NUL 2>&1 +SET /a COUNT=0 +IF EXIST %WINDIR%\adb.exe DEL %WINDIR%\adb.exe /f /q 1>nul 2>>%USERPROFILE%\Desktop\adb-installer.log +IF EXIST %WINDIR%\AdbWinApi.dll DEL %WINDIR%\AdbWinApi.dll /f /q 1>nul 2>>%USERPROFILE%\Desktop\adb-installer.log +IF EXIST %WINDIR%\AdbWinUsbApi.dll DEL %WINDIR%\AdbWinUsbApi.dll /f /q 1>nul 2>>%USERPROFILE%\Desktop\adb-installer.log +IF EXIST %WINDIR%\fastboot.exe DEL %WINDIR%\fastboot.exe /f /q 1>nul 2>>%USERPROFILE%\Desktop\adb-installer.log +XCOPY adb\adb.exe %USERPROFILE%\adb\ /y /q 1>nul 2>>%USERPROFILE%\Desktop\adb-installer.log && SET /a COUNT=%COUNT%+1 +XCOPY adb\AdbWinApi.dll %USERPROFILE%\adb\ /y /q 1>nul 2>>%USERPROFILE%\Desktop\adb-installer.log && SET /a COUNT=%COUNT%+1 +XCOPY adb\AdbWinUsbApi.dll %USERPROFILE%\adb\ /y /q 1>nul 2>>%USERPROFILE%\Desktop\adb-installer.log && SET /a COUNT=%COUNT%+1 +XCOPY adb\fastboot.exe %USERPROFILE%\adb\ /y /q 1>nul 2>>%USERPROFILE%\Desktop\adb-installer.log && SET /a COUNT=%COUNT%+1 +ECHO %COUNT% file(s) copied. +:PATH_U +ECHO %PATH% > PATH.TMP +ver > nul +FIND "%USERPROFILE%\adb" PATH.TMP > nul 2>&1 +IF %ERRORLEVEL% LSS 1 GOTO DRV +VER | FIND "5.1" > NUL 2>&1 +IF %ERRORLEVEL% LSS 1 xp\SETX.exe PATH "%PATH%;%USERPROFILE%\adb" 2>>%USERPROFILE%\Desktop\adb-installer.log && GOTO DRV +SETX PATH "%PATH%;%USERPROFILE%\adb" 2>>%USERPROFILE%\Desktop\adb-installer.log +GOTO DRV +:ADB_S +ECHO( +ECHO Installing ADB and Fastboot ... (system-wide) +ECHO( +ADB kill-server > NUL 2>&1 +SET /a COUNT=0 +IF EXIST %WINDIR%\adb.exe DEL %WINDIR%\adb.exe /f /q 1>nul 2>>%USERPROFILE%\Desktop\adb-installer.log +IF EXIST %WINDIR%\AdbWinApi.dll DEL %WINDIR%\AdbWinApi.dll /f /q 1>nul 2>>%USERPROFILE%\Desktop\adb-installer.log +IF EXIST %WINDIR%\AdbWinUsbApi.dll DEL %WINDIR%\AdbWinUsbApi.dll /f /q 1>nul 2>>%USERPROFILE%\Desktop\adb-installer.log +IF EXIST %WINDIR%\fastboot.exe DEL %WINDIR%\fastboot.exe /f /q 1>nul 2>>%USERPROFILE%\Desktop\adb-installer.log +XCOPY adb\adb.exe %SYSTEMDRIVE%\adb\ /y /q 1>nul 2>>%USERPROFILE%\Desktop\adb-installer.log && SET /a COUNT=%COUNT%+1 +XCOPY adb\AdbWinApi.dll %SYSTEMDRIVE%\adb\ /y /q 1>nul 2>>%USERPROFILE%\Desktop\adb-installer.log && SET /a COUNT=%COUNT%+1 +XCOPY adb\AdbWinUsbApi.dll %SYSTEMDRIVE%\adb\ /y /q 1>nul 2>>%USERPROFILE%\Desktop\adb-installer.log && SET /a COUNT=%COUNT%+1 +XCOPY adb\fastboot.exe %SYSTEMDRIVE%\adb\ /y /q 1>nul 2>>%USERPROFILE%\Desktop\adb-installer.log && SET /a COUNT=%COUNT%+1 +ECHO %COUNT% file(s) copied. +:PATH_S +ECHO %PATH% > PATH.TMP +ver > nul +FIND "%SYSTEMDRIVE%\adb" PATH.TMP > nul 2>&1 +IF %ERRORLEVEL% LSS 1 GOTO DRV +VER | FIND "5.1" > NUL 2>&1 +IF %ERRORLEVEL% LSS 1 xp\SETX.exe PATH "%PATH%;%SYSTEMDRIVE%\adb" /m 2>>%USERPROFILE%\Desktop\adb-installer.log && GOTO DRV +SETX PATH "%PATH%;%SYSTEMDRIVE%\adb" /m 2>>%USERPROFILE%\Desktop\adb-installer.log +:DRV +DEL PATH.TMP +ECHO( +SET /P ANSWER=Do you want to install device drivers? (Y/N) + IF /i {%ANSWER%}=={y} (GOTO DRIVER) + IF /i {%ANSWER%}=={yes} (GOTO DRIVER) + IF /i {%ANSWER%}=={n} (GOTO FINISH) + IF /i {%ANSWER%}=={no} (GOTO FINISH) +ECHO Bad answer! Use only Y/N or Yes/No +GOTO DRV +:DRIVER +IF DEFINED programfiles(x86) GOTO x64 +:x86 +ECHO( +ECHO Installing 32-bit driver ... +ECHO Please continue driver installation ... +PING localhost -n 1 >NUL +START /wait driver\DPInst_x86 /f 2>>%USERPROFILE%\Desktop\adb-installer.log +GOTO FINISH +:x64 +ECHO( +ECHO Installing 64-bit driver ... +ECHO Please continue driver installation ... +PING localhost -n 1 >NUL +START /wait driver\DPInst_x64 /f 2>>%USERPROFILE%\Desktop\adb-installer.log +:FINISH +ECHO( +ECHO All done! +CALL :LOG %USERPROFILE%\Desktop\adb-installer.log +:LOG +IF %~z1 == 0 DEL %USERPROFILE%\Desktop\adb-installer.log /f /q > nul 2>&1 +PING localhost -n 2 >NUL +EXIT \ No newline at end of file diff --git a/ADB-FB-GUI/exec/xp/SETX.exe b/ADB-FB-GUI/exec/xp/SETX.exe new file mode 100755 index 0000000..00d6dc6 Binary files /dev/null and b/ADB-FB-GUI/exec/xp/SETX.exe differ diff --git a/APPX Installer/APPX Installer.au3 b/APPX Installer/APPX Installer.au3 new file mode 100755 index 0000000..aa7c211 --- /dev/null +++ b/APPX Installer/APPX Installer.au3 @@ -0,0 +1,23 @@ + +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "TyleoAboutMe.au3" + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + diff --git a/APPX Installer/MetroGUI-UDF/MetroGUI_UDF.au3 b/APPX Installer/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/APPX Installer/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/APPX Installer/MetroGUI-UDF/MetroThemes.au3 b/APPX Installer/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/APPX Installer/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/APPX Installer/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/APPX Installer/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/APPX Installer/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/APPX Installer/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/APPX Installer/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/APPX Installer/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/APPX Installer/MetroGUI-UDF/_GUIDisable.au3 b/APPX Installer/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/APPX Installer/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/APPX Installer/Releases/.media b/APPX Installer/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/APPX Installer/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) + diff --git a/APPX Installer/TyleoAboutMe.au3 b/APPX Installer/TyleoAboutMe.au3 new file mode 100755 index 0000000..75ff526 --- /dev/null +++ b/APPX Installer/TyleoAboutMe.au3 @@ -0,0 +1,10 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/Android-ADB-F-GUI/Android-ADB-F-GUI.au3 b/Android-ADB-F-GUI/Android-ADB-F-GUI.au3 new file mode 100755 index 0000000..aa7c211 --- /dev/null +++ b/Android-ADB-F-GUI/Android-ADB-F-GUI.au3 @@ -0,0 +1,23 @@ + +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "TyleoAboutMe.au3" + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + diff --git a/Android-ADB-F-GUI/MetroGUI-UDF/MetroGUI_UDF.au3 b/Android-ADB-F-GUI/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/Android-ADB-F-GUI/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/Android-ADB-F-GUI/MetroGUI-UDF/MetroThemes.au3 b/Android-ADB-F-GUI/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/Android-ADB-F-GUI/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/Android-ADB-F-GUI/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/Android-ADB-F-GUI/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/Android-ADB-F-GUI/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/Android-ADB-F-GUI/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/Android-ADB-F-GUI/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/Android-ADB-F-GUI/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/Android-ADB-F-GUI/MetroGUI-UDF/_GUIDisable.au3 b/Android-ADB-F-GUI/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/Android-ADB-F-GUI/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/Android-ADB-F-GUI/Releases/.media b/Android-ADB-F-GUI/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/Android-ADB-F-GUI/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) + diff --git a/Android-ADB-F-GUI/TyleoAboutMe.au3 b/Android-ADB-F-GUI/TyleoAboutMe.au3 new file mode 100755 index 0000000..75ff526 --- /dev/null +++ b/Android-ADB-F-GUI/TyleoAboutMe.au3 @@ -0,0 +1,10 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/AntiLock/AntiLock.au3 b/AntiLock/AntiLock.au3 new file mode 100755 index 0000000..aa7c211 --- /dev/null +++ b/AntiLock/AntiLock.au3 @@ -0,0 +1,23 @@ + +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "TyleoAboutMe.au3" + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + diff --git a/AntiLock/MetroGUI-UDF/MetroGUI_UDF.au3 b/AntiLock/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/AntiLock/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/AntiLock/MetroGUI-UDF/MetroThemes.au3 b/AntiLock/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/AntiLock/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/AntiLock/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/AntiLock/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/AntiLock/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/AntiLock/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/AntiLock/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/AntiLock/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/AntiLock/MetroGUI-UDF/_GUIDisable.au3 b/AntiLock/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/AntiLock/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/AntiLock/Releases/.media b/AntiLock/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/AntiLock/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) + diff --git a/AntiLock/TyleoAboutMe.au3 b/AntiLock/TyleoAboutMe.au3 new file mode 100755 index 0000000..75ff526 --- /dev/null +++ b/AntiLock/TyleoAboutMe.au3 @@ -0,0 +1,10 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/AutoLogon Manager/AutoLogon Manager.au3 b/AutoLogon Manager/AutoLogon Manager.au3 new file mode 100755 index 0000000..e347e9e --- /dev/null +++ b/AutoLogon Manager/AutoLogon Manager.au3 @@ -0,0 +1,208 @@ +#RequireAdmin +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=AutoLogon Manager.ico +#AutoIt3Wrapper_Outfile_x64=..\..\Logiciels\AutoLogon Manager.exe +#AutoIt3Wrapper_Res_Comment=Autologon Manager +#AutoIt3Wrapper_Res_Description=Autologon Manager +#AutoIt3Wrapper_Res_Fileversion=1.0.4.12 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=Autologon Manager +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "TyleoAboutMe.au3" + +$CurrentVer = FileGetVersion(@AutoItExe) + +$ProgName = "Autologon Manager " & $CurrentVer + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +$NoticeConfirm = _Metro_MsgBox(4,"NOTICE - TYLEO SOFTWARES FOR ADMIN'S","WARNING - THIS SOFTWARE CAN CREATE AND MANAGE AUTOMATIC LOGON. THE USE OF THIS SOFTWARE IS AT YOUR OWN RISK. WE STRONGLY DONT RECOMMEND TO CONFIGURE AN AUTOLOGON ON AN ADMINISTRATOR ACCOUNT, AND EVEN MORE DOMAIN ADMIN ACCOUNT. THIS SOFTWARE ARE PROVIDED WITH THE AS-IS BASIS. SELECT YES/OUI IF YOU UNDERSTAND THE RISK.") + +if $NoticeConfirm = "No" Then + Exit(0) +EndIf + +$Win_Logon = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" + +$Win_AutoUser = "DefaultUserName" +$Win_AutoPass = "DefaultPassword" +$Win_AutoDomain = "DefaultDomainName" + +$Win_AutologonActivation = "AutoAdminLogon" + +$Win_Enabled = "1" +$Win_Disabled = "0" + + + +#include +#include +#include +#include +#include +#Region ### START Koda GUI section ### Form= +Global $Form1 = GUICreate("Autologon Manager " & $CurrentVer, 483, 163, 236, 242) +GUISetFont(14, 400, 0, "Segoe UI") +Global $Label1 = GUICtrlCreateLabel("Username", 8, 8, 94, 29) +Global $Label2 = GUICtrlCreateLabel("Password", 8, 48, 94, 29) +Global $Label3 = GUICtrlCreateLabel("Domain", 8, 88, 94, 29) +Global $AutoUser = GUICtrlCreateInput("", 104, 8, 273, 28) +GUICtrlSetFont(-1, 11, 400, 0, "Segoe UI Light") +Global $AutoPass = GUICtrlCreateInput("", 104, 48, 273, 28) +GUICtrlSetFont(-1, 11, 400, 0, "Segoe UI Light") +Global $AutoDomain = GUICtrlCreateInput("", 104, 88, 273, 28) +GUICtrlSetFont(-1, 11, 400, 0, "Segoe UI Light") +Global $OneClear = GUICtrlCreateButton("🧹", 384, 8, 25, 25) +GUICtrlSetTip(-1,"Clear Input") +GUICtrlSetCursor(-1,0) +Global $OneRead = GUICtrlCreateButton("🔽", 416, 8, 25, 25) +GUICtrlSetTip(-1,"Get Active Value") +GUICtrlSetCursor(-1,0) +Global $OneRemove = GUICtrlCreateButton("❌", 448, 8, 25, 25) +GUICtrlSetTip(-1,"Remove Key") +GUICtrlSetCursor(-1,0) +Global $TwoClear = GUICtrlCreateButton("🧹", 384, 48, 25, 25) +GUICtrlSetTip(-1,"Clear Input") +GUICtrlSetCursor(-1,0) +Global $TwoRead = GUICtrlCreateButton("🔽", 416, 48, 25, 25) +GUICtrlSetTip(-1,"Get Active Value") +GUICtrlSetCursor(-1,0) +Global $TwoRemove = GUICtrlCreateButton("❌", 448, 48, 25, 25) +GUICtrlSetTip(-1,"Remove Key") +GUICtrlSetCursor(-1,0) +Global $ThreeClear = GUICtrlCreateButton("🧹", 384, 88, 25, 25) +GUICtrlSetTip(-1,"Clear Input") +GUICtrlSetCursor(-1,0) +Global $ThreeRead = GUICtrlCreateButton("🔽", 416, 88, 25, 25) +GUICtrlSetTip(-1,"Get Active Value") +GUICtrlSetCursor(-1,0) +Global $ThreeRemove = GUICtrlCreateButton("❌", 448, 88, 25, 25) +GUICtrlSetTip(-1,"Remove Key") +GUICtrlSetCursor(-1,0) + +Global $AutologonState = GUICtrlCreateButton("STATE : OFF", 380, 120, 90, 33) +GUICtrlSetTip(-1,"Cancel and Exit") +GUICtrlSetFont(-1, 8,900) +GUICtrlSetBkColor(-1,0xCC0000) +GUICtrlSetColor(-1,0xFFFFFF) + +Global $ApplyEnable = GUICtrlCreateButton("APPLY && ENABLE", 252, 120, 120, 33) +GUICtrlSetTip(-1,"Save Configuration and Enable Autologon") +GUICtrlSetCursor(-1,0) +GUICtrlSetFont(-1, 8,900) +Global $AutologonDisable = GUICtrlCreateButton("DISABLE", 8, 120, 120, 33) +GUICtrlSetTip(-1,"Disable Autologon") +GUICtrlSetCursor(-1,0) +GUICtrlSetFont(-1, 8,900) +Global $Exit = GUICtrlCreateButton("CANCEL", 130, 120, 120, 33) +GUICtrlSetTip(-1,"Cancel and Exit") +GUICtrlSetCursor(-1,0) +GUICtrlSetFont(-1, 8,900) +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### +AutologonStateCheck() + +$OneReg = RegRead($Win_Logon,$Win_AutoUser) + GUICtrlSetData($AutoUser,$OneReg) +$TwoReg = RegRead($Win_Logon,$Win_AutoPass) + GUICtrlSetData($AutoPass,$TwoReg) +$ThreeReg = RegRead($Win_Logon,$Win_AutoDomain) + GUICtrlSetData($AutoDomain,$ThreeReg) + + +While 1 + $nMsg = GUIGetMsg() + AutologonStateCheck() + Switch $nMsg + Case $GUI_EVENT_CLOSE, $Exit + Exit + + Case $OneClear + GUICtrlSetData($AutoUser,"") + + Case $TwoClear + GUICtrlSetData($AutoPass,"") + + Case $ThreeClear + GUICtrlSetData($AutoDomain,"") + + Case $OneRead + $OneReg = RegRead($Win_Logon,$Win_AutoUser) + GUICtrlSetData($AutoUser,$OneReg) + + Case $TwoRead + $TwoReg = RegRead($Win_Logon,$Win_AutoPass) + GUICtrlSetData($AutoPass,$TwoReg) + + Case $ThreeRead + $ThreeReg = RegRead($Win_Logon,$Win_AutoDomain) + GUICtrlSetData($AutoDomain,$ThreeReg) + + Case $OneRemove + RegDelete($Win_Logon,$Win_AutoUser) + MsgBox(0,"Removed","Key " & $Win_Logon & "\" & $Win_AutoUser & " Removed.", 2) + GUICtrlSetData($AutoUser,"") + + Case $TwoRemove + RegDelete($Win_Logon,$Win_AutoPass) + MsgBox(0,"Removed","Key " & $Win_Logon & "\" & $Win_AutoPass & " Removed.", 2) + GUICtrlSetData($AutoPass,"") + + Case $ThreeRemove + RegDelete($Win_Logon,$Win_AutoDomain) + MsgBox(0,"Removed","Key " & $Win_Logon & "\" & $Win_AutoDomain & " Removed.", 2) + GUICtrlSetData($AutoDomain,"") + + Case $AutologonDisable + RegWrite($Win_Logon,$Win_AutologonActivation,"REG_SZ","0") + + Case $ApplyEnable + $Apply_AutoUser = GUICtrlRead($AutoUser) + $Apply_AutoPass = GUICtrlRead($AutoPass) + $Apply_AutoDomain = GUICtrlRead($AutoDomain) + if $Apply_AutoUser = "" Then + MsgBox(0+16,"No Username Provided","No username provided. You cannot apply Automatic Logon without username.",3) + Else + RegWrite($Win_Logon,$Win_AutologonActivation,"REG_SZ","1") + RegWrite($Win_Logon,$Win_AutoUser,"REG_SZ",$Apply_AutoUser) + RegWrite($Win_Logon,$Win_AutoPass,"REG_SZ",$Apply_AutoPass) + RegWrite($Win_Logon,$Win_AutoDomain,"REG_SZ",$Apply_AutoDomain) + AutologonStateCheck() + $RebootAsk = MsgBox(4,"Success","Autologon Applied and Activated." & @CRLF & "Start a try ? (Reboot after 5 seconds)") + ; ConsoleWrite($RebootAsk) + if $RebootAsk = "6" Then + Run("shutdown -r -t 5") + Exit(0) + EndIf + EndIf + + EndSwitch +WEnd + +Func AutologonStateCheck() + $ALState = RegRead($Win_Logon,$Win_AutologonActivation) + if $ALState = "1" Then + GUICtrlSetData($AutologonState,"STATE : ON") + GUICtrlSetBkColor($AutologonState,0x09A600) + Else + GUICtrlSetData($AutologonState,"STATE : OFF") + GUICtrlSetBkColor($AutologonState,0xD50000) + EndIf + Sleep(40) + Return True +EndFunc \ No newline at end of file diff --git a/AutoLogon Manager/AutoLogon Manager.ico b/AutoLogon Manager/AutoLogon Manager.ico new file mode 100755 index 0000000..e5cb567 Binary files /dev/null and b/AutoLogon Manager/AutoLogon Manager.ico differ diff --git a/AutoLogon Manager/MetroGUI-UDF/MetroGUI_UDF.au3 b/AutoLogon Manager/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/AutoLogon Manager/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/AutoLogon Manager/MetroGUI-UDF/MetroThemes.au3 b/AutoLogon Manager/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/AutoLogon Manager/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/AutoLogon Manager/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/AutoLogon Manager/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/AutoLogon Manager/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/AutoLogon Manager/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/AutoLogon Manager/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/AutoLogon Manager/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/AutoLogon Manager/MetroGUI-UDF/_GUIDisable.au3 b/AutoLogon Manager/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/AutoLogon Manager/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/AutoLogon Manager/Releases/.media b/AutoLogon Manager/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/AutoLogon Manager/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) + diff --git a/AutoLogon Manager/Releases/AutoLogon Manager.exe b/AutoLogon Manager/Releases/AutoLogon Manager.exe new file mode 100755 index 0000000..5492fad Binary files /dev/null and b/AutoLogon Manager/Releases/AutoLogon Manager.exe differ diff --git a/AutoLogon Manager/TyleoAboutMe.au3 b/AutoLogon Manager/TyleoAboutMe.au3 new file mode 100755 index 0000000..75ff526 --- /dev/null +++ b/AutoLogon Manager/TyleoAboutMe.au3 @@ -0,0 +1,10 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/AutomatedClockSync/AutomatedClockSync NoWait.au3 b/AutomatedClockSync/AutomatedClockSync NoWait.au3 new file mode 100755 index 0000000..fd3cb09 --- /dev/null +++ b/AutomatedClockSync/AutomatedClockSync NoWait.au3 @@ -0,0 +1,43 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=Sans titre (1).ico +#AutoIt3Wrapper_Outfile=..\..\Logiciels\AutomatedClockSync_NW_32-LE.exe +#AutoIt3Wrapper_Outfile_x64=..\..\Logiciels\AutomatedClockSync_NW_64.exe +#AutoIt3Wrapper_Compile_Both=y +#AutoIt3Wrapper_Res_Comment=ACS - Automated Clock Syncer NoWait +#AutoIt3Wrapper_Res_Description=ACS - Automated Clock Syncer NoWait +#AutoIt3Wrapper_Res_Fileversion=1.0.0.3 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=ACS +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +#NoTrayIcon +#RequireAdmin + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + +GetSoftDetails(@AutoItExe,"DEV") + +; Integrated : NTP_GetTime() +; Integrated : System_SetTime() + + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +ResyncTime() + +Func ResyncTime() + RunWait("net start w32time", "", @SW_HIDE) + RunWait("w32tm /resync", "", @SW_HIDE) +EndFunc \ No newline at end of file diff --git a/AutomatedClockSync/AutomatedClockSync.au3 b/AutomatedClockSync/AutomatedClockSync.au3 new file mode 100755 index 0000000..b717208 --- /dev/null +++ b/AutomatedClockSync/AutomatedClockSync.au3 @@ -0,0 +1,57 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=Sans titre (1).ico +#AutoIt3Wrapper_Outfile=..\..\Logiciels\AutomatedClockSync_32-LE.exe +#AutoIt3Wrapper_Outfile_x64=..\..\Logiciels\AutomatedClockSync_64.exe +#AutoIt3Wrapper_Compile_Both=y +#AutoIt3Wrapper_Res_Comment=ACS - Automated Clock Syncer +#AutoIt3Wrapper_Res_Description=ACS - Automated Clock Syncer +#AutoIt3Wrapper_Res_Fileversion=1.0.0.5 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=ACS +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +#RequireAdmin + +Opt("TrayMenuMode", 3) + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + +GetSoftDetails(@AutoItExe,"DEV") + +; Integrated : NTP_GetTime() +; Integrated : System_SetTime() + + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +ResyncTime() + +Global $TrayMenu_Resync = TrayCreateItem("Resync Now") +Global $TrayMenu_Exit = TrayCreateItem("Exit") + +While 1 + $nMSG =GUIGetMsg() + Switch $nMSG + Case $TrayMenu_Resync + ResyncTime() + Case $TrayMenu_Exit + Exit(0) + EndSwitch +WEnd + +Func ResyncTime() + RunWait("net start w32time", "", @SW_HIDE) + RunWait("w32tm /resync", "", @SW_HIDE) +EndFunc \ No newline at end of file diff --git a/AutomatedClockSync/Extensions.au3 b/AutomatedClockSync/Extensions.au3 new file mode 100755 index 0000000..4c3ee19 --- /dev/null +++ b/AutomatedClockSync/Extensions.au3 @@ -0,0 +1,34 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +; Color Accent +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +; Software Base Details +Func GetSoftDetails($Exe,$Stage) + Global $CurrentVersion,$CurrentName,$CurrentBaseVersion + $CurrentVersion = FileGetVersion($Exe,$FV_FILEVERSION) + $CurrentBaseVersion = FileGetVersion($Exe,$FV_PRODUCTVERSION) + $CurrentName = FileGetVersion($Exe,$FV_PRODUCTNAME) + if $Stage = "BETA" Then + $CurrentVersion = $CurrentVersion & "-beta" + Elseif $Stage = "RELEASE" or $Stage = "STABLE" Then + $CurrentVersion = $CurrentVersion & "-rel" + Else + $CurrentVersion = $CurrentVersion & "-dev" + EndIf + Return True +EndFunc + +; About Us +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/AutomatedClockSync/MetroGUI-UDF/MetroGUI_UDF.au3 b/AutomatedClockSync/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/AutomatedClockSync/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/AutomatedClockSync/MetroGUI-UDF/MetroThemes.au3 b/AutomatedClockSync/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/AutomatedClockSync/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/AutomatedClockSync/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/AutomatedClockSync/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/AutomatedClockSync/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/AutomatedClockSync/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/AutomatedClockSync/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/AutomatedClockSync/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/AutomatedClockSync/MetroGUI-UDF/_GUIDisable.au3 b/AutomatedClockSync/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/AutomatedClockSync/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/AutomatedClockSync/Projet.kxf b/AutomatedClockSync/Projet.kxf new file mode 100755 index 0000000..e8a2629 --- /dev/null +++ b/AutomatedClockSync/Projet.kxf @@ -0,0 +1,229 @@ + + + + 192 + 154 + 633 + 292 + Form1 + clBtnFace + DEFAULT_CHARSET + clWindowText + -13 + Segoe UI + + Menu1 + False + True + -1798701056 + 256 + 1.04 + False + False + False + False + -1 + 1 + 0 + 1 + + 96 + 15 + + + + + 586 + 56 + 28 + 28 + Owner + MainMenu1 + + + + + + 5 + 9 + 70 + 23 + Utilisateur + DEFAULT_CHARSET + clWindowText + -16 + Segoe UI + + False + 0 + False + 1342308608 + 0 + + + + + + + 5 + 32 + 41 + 23 + Poste + DEFAULT_CHARSET + clWindowText + -16 + Segoe UI + + False + 1 + False + 1342308608 + 0 + + + + + + + 258 + 66 + 100 + 19 + Descriptif Rapide + 2 + False + 1342308609 + 0 + + + + + + + 81 + 7 + 418 + 23 + 3 + Input1 + 1342374016 + 512 + DockHeight + + + + + + 500 + 7 + 109 + 23 + 4 + Input1 + 1342374016 + 512 + DockHeight + + + + + + 50 + 32 + 294 + 23 + 5 + Input3 + 1342374016 + 512 + DockHeight + + + + + + 1 + 86 + 615 + 146 + + +
  • Edit1
  • +
    +
    + 6 + 1345523908 + 512 + +
    + +
    + + + 372 + 33 + 239 + 23 + 7 + Input3 + 1342374016 + 512 + DockHeight + + + + + + 346 + 34 + 25 + 23 + Tel. + DEFAULT_CHARSET + clWindowText + -16 + Segoe UI + + False + 8 + False + 1342308608 + 0 + + + + + + + + + + MenuItem2 + + + + + MenuItem4 + + + + + + + + MenuItem1 + + + + + MenuItem3 + + + + + + + +
    +
    \ No newline at end of file diff --git a/AutomatedClockSync/README.md b/AutomatedClockSync/README.md new file mode 100755 index 0000000..ce6d680 --- /dev/null +++ b/AutomatedClockSync/README.md @@ -0,0 +1 @@ +Logiciel Tyleo Créé avec CNP \ No newline at end of file diff --git a/AutomatedClockSync/Releases/.media b/AutomatedClockSync/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/AutomatedClockSync/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) + diff --git a/AutomatedClockSync/Sans titre (1).ico b/AutomatedClockSync/Sans titre (1).ico new file mode 100755 index 0000000..b14d4dc Binary files /dev/null and b/AutomatedClockSync/Sans titre (1).ico differ diff --git a/AutomatedClockSync/TimeSync Failed.log b/AutomatedClockSync/TimeSync Failed.log new file mode 100755 index 0000000..abfc74f --- /dev/null +++ b/AutomatedClockSync/TimeSync Failed.log @@ -0,0 +1,2 @@ +2021/12/26 09:54:31 +UDPRecv failed - @error = -2 \ No newline at end of file diff --git a/Autostart Manager/Autostart Manager.au3 b/Autostart Manager/Autostart Manager.au3 new file mode 100755 index 0000000..aa7c211 --- /dev/null +++ b/Autostart Manager/Autostart Manager.au3 @@ -0,0 +1,23 @@ + +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "TyleoAboutMe.au3" + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + diff --git a/Autostart Manager/MetroGUI-UDF/MetroGUI_UDF.au3 b/Autostart Manager/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/Autostart Manager/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/Autostart Manager/MetroGUI-UDF/MetroThemes.au3 b/Autostart Manager/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/Autostart Manager/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/Autostart Manager/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/Autostart Manager/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/Autostart Manager/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/Autostart Manager/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/Autostart Manager/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/Autostart Manager/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/Autostart Manager/MetroGUI-UDF/_GUIDisable.au3 b/Autostart Manager/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/Autostart Manager/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/Autostart Manager/Releases/.media b/Autostart Manager/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/Autostart Manager/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) + diff --git a/Autostart Manager/TyleoAboutMe.au3 b/Autostart Manager/TyleoAboutMe.au3 new file mode 100755 index 0000000..75ff526 --- /dev/null +++ b/Autostart Manager/TyleoAboutMe.au3 @@ -0,0 +1,10 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/CNP.Exe b/CNP.Exe new file mode 100755 index 0000000..17125da Binary files /dev/null and b/CNP.Exe differ diff --git a/CNP_32.Exe b/CNP_32.Exe new file mode 100755 index 0000000..33dc95e Binary files /dev/null and b/CNP_32.Exe differ diff --git a/ChocoSetup/ChocoPackages.ini b/ChocoSetup/ChocoPackages.ini new file mode 100755 index 0000000..8b32c33 --- /dev/null +++ b/ChocoSetup/ChocoPackages.ini @@ -0,0 +1,2 @@ +[Packages] +PACKAGES= diff --git a/ChocoSetup/ChocolateyCustom.au3 b/ChocoSetup/ChocolateyCustom.au3 new file mode 100755 index 0000000..c0e05ed --- /dev/null +++ b/ChocoSetup/ChocolateyCustom.au3 @@ -0,0 +1,17 @@ +#RequireAdmin +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=SETUP_CUST.ico +#AutoIt3Wrapper_Outfile_x64=Releases\ChocolateyCustom.exe +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +if not FileExists(@ScriptDir & "\ChocoPackages.ini") Then + IniWrite(@ScriptDir & "\ChocoPackages.ini","Packages","PACKAGES","") + Exit(1) +EndIf + +$packages = IniRead(@ScriptDir & "\ChocoPackages.ini","Packages","PACKAGES","424242") + +if $packages = "424242" Then + Exit(1) +EndIf +Run("choco feature enable -n=allowGlobalConfirmation") +Run("choco install " & $packages) \ No newline at end of file diff --git a/ChocoSetup/ChocolateySetup.au3 b/ChocoSetup/ChocolateySetup.au3 new file mode 100755 index 0000000..26d848c --- /dev/null +++ b/ChocoSetup/ChocolateySetup.au3 @@ -0,0 +1,13 @@ +#RequireAdmin +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=SETUP.ico +#AutoIt3Wrapper_Outfile_x64=Releases\ChocoSetup.Exe +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +$ChocoGlobal = "choco feature enable -n=allowGlobalConfirmation" +$ChocoCMD = "Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" +Run("powershell" & " " & $ChocoCMD) +Run("cmd" & " /c " & $ChocoGlobal) + +If FileExists(@ScriptDir & "\ChocolateyCustom.exe") Then + Run(@ScriptDir & "\ChocolateyCustom.exe") +EndIf \ No newline at end of file diff --git a/ChocoSetup/ChocolateySetup.exe b/ChocoSetup/ChocolateySetup.exe new file mode 100755 index 0000000..2e673cd Binary files /dev/null and b/ChocoSetup/ChocolateySetup.exe differ diff --git a/ChocoSetup/Releases/ChocoPackages.ini b/ChocoSetup/Releases/ChocoPackages.ini new file mode 100755 index 0000000..e210612 --- /dev/null +++ b/ChocoSetup/Releases/ChocoPackages.ini @@ -0,0 +1,2 @@ +[Packages] +PACKAGES=youtube-dl ffmpeg axel wget curl git \ No newline at end of file diff --git a/ChocoSetup/Releases/ChocoSetup.Exe b/ChocoSetup/Releases/ChocoSetup.Exe new file mode 100755 index 0000000..9ccab84 Binary files /dev/null and b/ChocoSetup/Releases/ChocoSetup.Exe differ diff --git a/ChocoSetup/Releases/ChocolateyCustom.exe b/ChocoSetup/Releases/ChocolateyCustom.exe new file mode 100755 index 0000000..6db5eae Binary files /dev/null and b/ChocoSetup/Releases/ChocolateyCustom.exe differ diff --git a/ChocoSetup/SETUP.ico b/ChocoSetup/SETUP.ico new file mode 100755 index 0000000..46bf0c1 Binary files /dev/null and b/ChocoSetup/SETUP.ico differ diff --git a/ChocoSetup/SETUP_CUST.ico b/ChocoSetup/SETUP_CUST.ico new file mode 100755 index 0000000..2803d46 Binary files /dev/null and b/ChocoSetup/SETUP_CUST.ico differ diff --git a/Chrome InApp/Chrome InApp.au3 b/Chrome InApp/Chrome InApp.au3 new file mode 100755 index 0000000..aa7c211 --- /dev/null +++ b/Chrome InApp/Chrome InApp.au3 @@ -0,0 +1,23 @@ + +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "TyleoAboutMe.au3" + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + diff --git a/Chrome InApp/MetroGUI-UDF/MetroGUI_UDF.au3 b/Chrome InApp/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/Chrome InApp/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/Chrome InApp/MetroGUI-UDF/MetroThemes.au3 b/Chrome InApp/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/Chrome InApp/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/Chrome InApp/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/Chrome InApp/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/Chrome InApp/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/Chrome InApp/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/Chrome InApp/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/Chrome InApp/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/Chrome InApp/MetroGUI-UDF/_GUIDisable.au3 b/Chrome InApp/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/Chrome InApp/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/Chrome InApp/Releases/.media b/Chrome InApp/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/Chrome InApp/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) + diff --git a/Chrome InApp/TyleoAboutMe.au3 b/Chrome InApp/TyleoAboutMe.au3 new file mode 100755 index 0000000..75ff526 --- /dev/null +++ b/Chrome InApp/TyleoAboutMe.au3 @@ -0,0 +1,10 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/Color Picker/Aslinks Ico.ico b/Color Picker/Aslinks Ico.ico new file mode 100755 index 0000000..a1300d3 Binary files /dev/null and b/Color Picker/Aslinks Ico.ico differ diff --git a/Color Picker/Color Base (AutoIT Version)/MintGreen-0x2FE19A.aucolor b/Color Picker/Color Base (AutoIT Version)/MintGreen-0x2FE19A.aucolor new file mode 100755 index 0000000..f9b8f45 --- /dev/null +++ b/Color Picker/Color Base (AutoIT Version)/MintGreen-0x2FE19A.aucolor @@ -0,0 +1 @@ +0x2FE19A \ No newline at end of file diff --git a/Color Picker/ColorPicker For AutoIT Coder.au3 b/Color Picker/ColorPicker For AutoIT Coder.au3 new file mode 100755 index 0000000..c6b6701 --- /dev/null +++ b/Color Picker/ColorPicker For AutoIT Coder.au3 @@ -0,0 +1,386 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=Aslinks Ico.ico +#AutoIt3Wrapper_Outfile=..\..\Logiciels\HEXColorPicker_Unified_x32-x86.exe +#AutoIt3Wrapper_Outfile_x64=..\..\Logiciels\HEXColorPicker_Unified_x64.exe +#AutoIt3Wrapper_Compile_Both=y +#AutoIt3Wrapper_Res_Comment=HEX Color Picker Unified +#AutoIt3Wrapper_Res_Description=HEX Color Picker Unified +#AutoIt3Wrapper_Res_Fileversion=2.0.4.3 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=HEX Color Picker Unified +#AutoIt3Wrapper_Res_ProductVersion=2.0.4.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +#include +#include +#include +#include +#include +#include +#include "TyleoAboutMe.au3" + +; Fixed Color Vars +$FullWhite = "FFFFFF" +$FullBlack = "000000" +$MatrixGreen = "0DFF06" +$MatrixDarkBlue = "040033" +$DiscordDark = "2C2F33" +$Ice = "4ACBE1" +$GoogleGreen = "34A853" +$GoogleDark = "202124" +$GoogleBlue = "4285F4" +$GoogleRed = "EA4335" +$GoogleYellow = "FBBC05" +$Sand = "E3CCBA" +$Buttercup = "e49326" +$MicrosoftYellow = "FEF000" +$BrightPink = "FF06FF" +$Espresso = "784018" +$DiscordGray = "99AAB5" +$DiscordBluev1 = "5865F2" +$DiscordBluev2 = "404EED" +$FacebookClassic = "4267B2" +$FacebookBlue = "1877F2" +$Mint = "ACCCAC" +$MaterialBlue = "0080FF" +$Win11Blue = "0067B8" +$Magenta = "C219BF" + +$AltColor1 = "CC0000" +$AltColor2 = "9400EC" + +$CodeName = "ASLINKS" +$CurrentVer = FileGetVersion(@AutoItExe) & " " & $CodeName + +$Prog = "Color Picker for AutoIT " & $CurrentVer + +#Region ### START Koda GUI section ### Form= +Global $GUI = GUICreate($Prog, 460, 125, 295, 325) +Global $PickColor = GUICtrlCreateButton("Pick Color", 8, 55, 209, 41) +GUICtrlSetFont(-1, 12, 400, 0, "Segoe UI") +GUICtrlSetColor(-1,0x000000) +GUICtrlSetBkColor(-1,0xFFFFFF) +Global $HEX = GUICtrlCreateInput("", 8, 8, 209, 41, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$WS_EX_WINDOWEDGE)) +GUICtrlSetFont(-1, 20, 400, 0, "Segoe UI") +GUICtrlSetColor(-1,0x000000) +GUICtrlSetBkColor(-1,0xFFFFFF) +Global $GUI_Menu_File = GUICtrlCreateMenu("File") +Global $GUI_Menu_File_Save = GUICtrlCreateMenuItem("Save Color to Base",$GUI_Menu_File) +Global $GUI_Menu_File_OpenBase = GUICtrlCreateMenuItem("Open Color Base",$GUI_Menu_File) +Global $GUI_Menu_File_Refresh = GUICtrlCreateMenuItem("Refresh Color List",$GUI_Menu_File) +GUICtrlCreateMenuItem("",$GUI_Menu_File) +Global $GUI_Menu_File_Remove = GUICtrlCreateMenuItem("Delete this color",$GUI_Menu_File) + +Global $GUI_Menu_Color = GUICtrlCreateMenu("Color") +Global $GUI_Menu_Color_ExportNoAutoIT = GUICtrlCreateMenuItem("Copy Non AutoIT Color Code (Without '0x')",$GUI_Menu_Color) + +Global $GUI_Menu_Options = GUICtrlCreateMenu("Options") +Global $GUI_Menu_Options_EditCfg = GUICtrlCreateMenuItem("Edit Color Base Location",$GUI_Menu_Options) + +Global $GUI_Menu_About = GUICtrlCreateMenu("About") +Global $GUI_Menu_About_Dev = GUICtrlCreateMenuItem("Developers",$GUI_Menu_About) +Global $GUI_Menu_About_Ver = GUICtrlCreateMenuItem("Color Picker " & $CurrentVer,$GUI_Menu_About) +GUICtrlSetState($GUI_Menu_About_Ver,$GUI_DISABLE) + +; Color Fixed Set +Global $CFS_1 = GUICtrlCreateButton("", 380, 7, 15, 15) +DefineBkFromHex(-1, $GoogleDark) +GUICtrlSetTip(-1, "Google Dark") +GUICtrlSetCursor(-1, 0) +Global $CFS_2 = GUICtrlCreateButton("", 395, 7, 15, 15) +DefineBkFromHex(-1, $GoogleGreen) +GUICtrlSetTip(-1, "Google Green") +GUICtrlSetCursor(-1, 0) +Global $CFS_3 = GUICtrlCreateButton("", 410, 7, 15, 15) +DefineBkFromHex(-1, $GoogleRed) +GUICtrlSetTip(-1, "Google Red") +GUICtrlSetCursor(-1, 0) +Global $CFS_4 = GUICtrlCreateButton("", 425, 7, 15, 15) +DefineBkFromHex(-1, $GoogleYellow) +GUICtrlSetTip(-1, "Google Yellow") +GUICtrlSetCursor(-1, 0) +Global $CFS_5 = GUICtrlCreateButton("", 440, 7, 15, 15) +DefineBkFromHex(-1, $FacebookBlue) +GUICtrlSetTip(-1, "Facebook Blue") +GUICtrlSetCursor(-1, 0) +Global $CFS_6 = GUICtrlCreateButton("", 380, 25, 15, 15) +DefineBkFromHex(-1, $FacebookClassic) +GUICtrlSetTip(-1, "Facebook Classic Blue") +GUICtrlSetCursor(-1, 0) +Global $CFS_7 = GUICtrlCreateButton("", 395, 25, 15, 15) +DefineBkFromHex(-1, $DiscordBluev1) +GUICtrlSetTip(-1, "Discord Blue v1") +GUICtrlSetCursor(-1, 0) +Global $CFS_8 = GUICtrlCreateButton("", 410, 25, 15, 15) +DefineBkFromHex(-1, $DiscordBluev2) +GUICtrlSetTip(-1, "Discord Blue v2") +GUICtrlSetCursor(-1, 0) +Global $CFS_9 = GUICtrlCreateButton("", 425, 25, 15, 15) +DefineBkFromHex(-1, $DiscordDark) +GUICtrlSetTip(-1, "Discord Dark") +GUICtrlSetCursor(-1, 0) +Global $CFS_10 = GUICtrlCreateButton("", 440, 25, 15, 15) +DefineBkFromHex(-1, $DiscordGray) +GUICtrlSetTip(-1, "Discord Gray") +GUICtrlSetCursor(-1, 0) +Global $CFS_11 = GUICtrlCreateButton("", 380, 25 + 18, 15, 15) +DefineBkFromHex(-1, $Buttercup) +GUICtrlSetTip(-1, "Buttercup") +GUICtrlSetCursor(-1, 0) +Global $CFS_12 = GUICtrlCreateButton("", 395, 25 + 18, 15, 15) +DefineBkFromHex(-1, $Ice) +GUICtrlSetTip(-1, "Ice") +GUICtrlSetCursor(-1, 0) +Global $CFS_13 = GUICtrlCreateButton("", 410, 25 + 18, 15, 15) +DefineBkFromHex(-1, $MaterialBlue) +GUICtrlSetTip(-1, "Material Blue") +GUICtrlSetCursor(-1, 0) +Global $CFS_14 = GUICtrlCreateButton("", 425, 25 + 18, 15, 15) +DefineBkFromHex(-1, $Win11Blue) +GUICtrlSetTip(-1, "Windows 11 Blue") +GUICtrlSetCursor(-1, 0) +Global $CFS_15 = GUICtrlCreateButton("", 440, 25 + 18, 15, 15) +DefineBkFromHex(-1, $MatrixGreen) +GUICtrlSetTip(-1, "MATRIX Green") +GUICtrlSetCursor(-1, 0) +Global $CFS_16 = GUICtrlCreateButton("", 380, 25 + 36, 15, 15) +DefineBkFromHex(-1, $MatrixDarkBlue) +GUICtrlSetTip(-1, "MATRIX Dark Blue") +GUICtrlSetCursor(-1, 0) +Global $CFS_17 = GUICtrlCreateButton("", 395, 25 + 36, 15, 15) +DefineBkFromHex(-1, $Espresso) +GUICtrlSetTip(-1, "Espresso What Else") +GUICtrlSetCursor(-1, 0) +Global $CFS_18 = GUICtrlCreateButton("", 410, 25 + 36, 15, 15) +DefineBkFromHex(-1, $Sand) +GUICtrlSetTip(-1, "Sand") +GUICtrlSetCursor(-1, 0) +Global $CFS_19 = GUICtrlCreateButton("", 425, 25 + 36, 15, 15) +DefineBkFromHex(-1, $Mint) +GUICtrlSetTip(-1, "Mint") +GUICtrlSetCursor(-1, 0) +Global $CFS_20 = GUICtrlCreateButton("", 440, 25 + 36, 15, 15) +DefineBkFromHex(-1, $Magenta) +GUICtrlSetTip(-1, "Magenta") +GUICtrlSetCursor(-1, 0) +Global $CFS_21 = GUICtrlCreateButton("", 380, 25 + 54, 15, 15) +DefineBkFromHex(-1, $BrightPink) +GUICtrlSetTip(-1, "Bright Pink") +GUICtrlSetCursor(-1, 0) +Global $CFS_22 = GUICtrlCreateButton("", 395, 25 + 54, 15, 15) +DefineBkFromHex(-1, $AltColor1) +GUICtrlSetTip(-1, "Dev Choice #1") +GUICtrlSetCursor(-1, 0) +Global $CFS_23 = GUICtrlCreateButton("", 410, 25 + 54, 15, 15) +DefineBkFromHex(-1, $AltColor2) +GUICtrlSetTip(-1, "Dev Choice #2") +GUICtrlSetCursor(-1, 0) +Global $CFS_24 = GUICtrlCreateButton("", 425, 25 + 54, 15, 15) +DefineBkFromHex(-1, $FullBlack) +GUICtrlSetTip(-1, "Perfect Black (PitchBlack)") +GUICtrlSetCursor(-1, 0) +Global $CFS_25 = GUICtrlCreateButton("", 440, 25 + 54, 15, 15) +DefineBkFromHex(-1, $FullWhite) +GUICtrlSetTip(-1, "Perfect White (FluxWhite)") +GUICtrlSetCursor(-1, 0) + +; File List +Global $GUI_ColorBase_List = GUICtrlCreateList("0x000000",220,8,155,97, -1, $WS_EX_WINDOWEDGE) +GUICtrlSetFont(-1,8,900,"","Segoe UI") +GUICtrlSetData($GUI_ColorBase_List,"0xFFFFFF") +; + +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +if Not FileExists(@ScriptDir & "\ColorsLocation_AutoIT.ini") Then + IniWrite(@ScriptDir & "\ColorsLocation_AutoIT.ini","Colors Location","Dir",@ScriptDir & "\Color Base (AutoIT Version)") +EndIf + +$ColorBase = IniRead(@ScriptDir & "\ColorsLocation_AutoIT.ini","Colors Location","Dir",@ScriptDir & "\Color Base (AutoIT Version)") + +if Not FileExists($ColorBase) Then + DirCreate($ColorBase) +EndIf + +ColorBaseRefresh() + +$NextLiveColor = GUICtrlRead($HEX) + if StringInStr($NextLiveColor,"0x","",1) Then + GUICtrlSetColor($HEX,$NextLiveColor) + GUISetBkColor($NextLiveColor) + EndIf + +While 1 + $nMsg = GUIGetMsg() + LiveColor() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + + Case $CFS_1 + GUICtrlSetData($HEX, "0x" & $GoogleDark) + Case $CFS_2 + GUICtrlSetData($HEX, "0x" & $GoogleGreen) + Case $CFS_3 + GUICtrlSetData($HEX, "0x" & $GoogleRed) + Case $CFS_4 + GUICtrlSetData($HEX, "0x" & $GoogleYellow) + Case $CFS_5 + GUICtrlSetData($HEX, "0x" & $FacebookBlue) + Case $CFS_6 + GUICtrlSetData($HEX, "0x" & $FacebookClassic) + Case $CFS_7 + GUICtrlSetData($HEX, "0x" & $DiscordBluev1) + Case $CFS_8 + GUICtrlSetData($HEX, "0x" & $DiscordBluev2) + Case $CFS_9 + GUICtrlSetData($HEX, "0x" & $DiscordDark) + Case $CFS_10 + GUICtrlSetData($HEX, "0x" & $DiscordGray) + Case $CFS_11 + GUICtrlSetData($HEX, "0x" & $Buttercup) + Case $CFS_12 + GUICtrlSetData($HEX, "0x" & $Ice) + Case $CFS_13 + GUICtrlSetData($HEX, "0x" & $MaterialBlue) + Case $CFS_14 + GUICtrlSetData($HEX, "0x" & $Win11Blue) + Case $CFS_15 + GUICtrlSetData($HEX, "0x" & $MatrixGreen) + Case $CFS_16 + GUICtrlSetData($HEX, "0x" & $MatrixDarkBlue) + Case $CFS_17 + GUICtrlSetData($HEX, "0x" & $Espresso) + Case $CFS_18 + GUICtrlSetData($HEX, "0x" & $Sand) + Case $CFS_19 + GUICtrlSetData($HEX, "0x" & $Mint) + Case $CFS_20 + GUICtrlSetData($HEX, "0x" & $Magenta) + Case $CFS_21 + GUICtrlSetData($HEX, "0x" & $BrightPink) + Case $CFS_22 + GUICtrlSetData($HEX, "0x" & $AltColor1) + Case $CFS_23 + GUICtrlSetData($HEX, "0x" & $AltColor2) + Case $CFS_24 + GUICtrlSetData($HEX, "0x" & $FullBlack) + Case $CFS_25 + GUICtrlSetData($HEX, "0x" & $FullWhite) + + Case $GUI_Menu_Options_EditCfg + $nLocation = FileSelectFolder("Select a new location for your Color Base",$ColorBase) + if $nLocation = "" Then + ColorBaseRefresh() + Else + IniWrite(@ScriptDir & "\ColorsLocation_AutoIT.ini","Colors Location","Dir",$nLocation) + $ColorBase = $nLocation + ColorBaseRefresh() + EndIf + + Case $GUI_Menu_File_Remove + $tFile = GUICtrlRead($GUI_ColorBase_List) + if $tFile = "" Then + ; Nothing + Else + $confirm = InputBox("Confirmation Dialog","Please confirm the deletion of this color" & @CRLF & "Target : " & $tFile & @CRLF & "Enter 'YES' to confirm and enter !","","","",150) + if $confirm = "YES" Then + FileDelete($ColorBase & "\" & $tFile) + ColorBaseRefresh() + EndIf + EndIf + + Case $GUI_Menu_File_Refresh + ColorBaseRefresh() + + Case $GUI_Menu_About_Dev + TyleoAbout($Prog & " Unified Edition") + + Case $GUI_Menu_Color_ExportNoAutoIT + $NoITClip = GUICtrlRead($HEX) + $NoITClip = StringTrimLeft($NoITClip,2) + ClipPut($NoITClip) + + Case $PickColor + $hColor = _ChooseColor(2) + if $hColor = "-1" Then + ; Nothing + Else + GUISetBkColor($hColor) + GUICtrlSetBkColor($HEX,$hColor) + GUICtrlSetBkColor($GUI_ColorBase_List,$hColor) + GUICtrlSetBkColor($PickColor,$hColor) + GUICtrlSetData($HEX,$hColor) + ClipPut($hColor) + EndIf + + Case $GUI_ColorBase_List + $iFileColor = GUICtrlRead($GUI_ColorBase_List) + $oFileOpen = FileOpen($ColorBase & "\" & $iFileColor & ".aucolor") + $iColor = FileRead($oFileOpen) + FileClose($oFileOpen) + GUISetBkColor($iColor) + GUICtrlSetBkColor($HEX,$iColor) + GUICtrlSetColor($HEX,0xFFFFFF) + GUICtrlSetBkColor($GUI_ColorBase_List,$iColor) + GUICtrlSetBkColor($PickColor,$iColor) + GUICtrlSetData($HEX,$iColor) + ClipPut($iColor) + + + Case $GUI_Menu_File_Save + $sName = InputBox("Color Human Readable Name","Enter the name of your color, You can" & @CRLF & "Choose anything.","","","",140) + + $sColor = GUICtrlRead($HEX) + if $sName = "" Then + $sFileName = $sColor & ".aucolor" + Else + $sFileName = $sName & "-" & $sColor & ".aucolor" + EndIf + $sFileOpen = FileOpen($ColorBase & "\" & $sFileName,2) + FileWrite($sFileOpen,$sColor) + FileClose($sFileOpen) + ColorBaseRefresh() + + + Case $GUI_Menu_File_OpenBase + ShellExecute($ColorBase) + + EndSwitch +WEnd + +Func ColorBaseRefresh() + GUICtrlSetData($GUI_ColorBase_List,"") + $cColorFiles = _FileListToArray($ColorBase,"*.aucolor",$FLTA_FILES,False) + _ArrayDelete($cColorFiles, 0) + _ArrayTrim($cColorFiles,8,1) + $cFiles = _ArrayToString($cColorFiles) + GUICtrlSetData($GUI_ColorBase_List,$cFiles) + $cCheck = GUICtrlRead($GUI_ColorBase_List) + if $cCheck = "-1" Then + GUICtrlSetData($GUI_ColorBase_List,"") + EndIf +EndFunc + +Func LiveColor() + $LiveColor = GUICtrlRead($HEX) + if $LiveColor = $NextLiveColor Then + ; Nothing + Else + $NextLiveColor = GUICtrlRead($HEX) + if StringInStr($NextLiveColor,"0x","",1) Then + GUICtrlSetBkColor($HEX,$NextLiveColor) + GUICtrlSetBkColor($GUI_ColorBase_List,$NextLiveColor) + GUICtrlSetBkColor($PickColor,$NextLiveColor) + GUISetBkColor($NextLiveColor) + EndIf + EndIf +EndFunc + +Func DefineBkFromHex($Target, $ColorCode) + $ColorCode = "0x" & $ColorCode + GUICtrlSetBkColor($Target, $ColorCode) +EndFunc \ No newline at end of file diff --git a/Color Picker/ColorPicker For AutoIT Coder_Icon.ico b/Color Picker/ColorPicker For AutoIT Coder_Icon.ico new file mode 100755 index 0000000..4c26c3b Binary files /dev/null and b/Color Picker/ColorPicker For AutoIT Coder_Icon.ico differ diff --git a/Color Picker/ColorPicker_Icon.ico b/Color Picker/ColorPicker_Icon.ico new file mode 100755 index 0000000..d43fd80 Binary files /dev/null and b/Color Picker/ColorPicker_Icon.ico differ diff --git a/Color Picker/ColorsLocation_AutoIT.ini b/Color Picker/ColorsLocation_AutoIT.ini new file mode 100755 index 0000000..c1e34de --- /dev/null +++ b/Color Picker/ColorsLocation_AutoIT.ini @@ -0,0 +1,2 @@ +[Colors Location] +Dir=c:\Users\Tyleo\OneDrive\Tyleo\Dev\Color Picker\Color Base (AutoIT Version) diff --git a/Color Picker/ColorsLocation_NoIT.ini b/Color Picker/ColorsLocation_NoIT.ini new file mode 100755 index 0000000..431a0dd --- /dev/null +++ b/Color Picker/ColorsLocation_NoIT.ini @@ -0,0 +1,2 @@ +[Colors Location] +Dir=c:\Users\Tyleo\OneDrive\Tyleo\Dev\Color Picker\Color Base (Non AutoIT Version) diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0x000000-Full Black.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x000000-Full Black.aucolor new file mode 100755 index 0000000..def720a --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x000000-Full Black.aucolor @@ -0,0 +1 @@ +0x000000 \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0x0067B8-Windows 11 Blue.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x0067B8-Windows 11 Blue.aucolor new file mode 100755 index 0000000..0106b90 --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x0067B8-Windows 11 Blue.aucolor @@ -0,0 +1 @@ +0x0067B8 \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0x0080FF-Material Blue.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x0080FF-Material Blue.aucolor new file mode 100755 index 0000000..aa3c7f1 --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x0080FF-Material Blue.aucolor @@ -0,0 +1 @@ +0x0080FF \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0x040033-Matrix Dark Blue.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x040033-Matrix Dark Blue.aucolor new file mode 100755 index 0000000..1074ed4 --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x040033-Matrix Dark Blue.aucolor @@ -0,0 +1 @@ +0x040033 \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0x0DFF06-Matrix Green.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x0DFF06-Matrix Green.aucolor new file mode 100755 index 0000000..9d528bc --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x0DFF06-Matrix Green.aucolor @@ -0,0 +1 @@ +0x0DFF06 \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0x1877F2-Facebook Blue.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x1877F2-Facebook Blue.aucolor new file mode 100755 index 0000000..8d94ffb --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x1877F2-Facebook Blue.aucolor @@ -0,0 +1 @@ +0x1877F2 \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0x202124-Google Dark.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x202124-Google Dark.aucolor new file mode 100755 index 0000000..d2c4ced --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x202124-Google Dark.aucolor @@ -0,0 +1 @@ +0x202124 \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0x2C2F33-Discord Dark.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x2C2F33-Discord Dark.aucolor new file mode 100755 index 0000000..157aad3 --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x2C2F33-Discord Dark.aucolor @@ -0,0 +1 @@ +0x2C2F33 \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0x34A853-Google Green.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x34A853-Google Green.aucolor new file mode 100755 index 0000000..4e75f62 --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x34A853-Google Green.aucolor @@ -0,0 +1 @@ +0x34A853 \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0x404EED-Discord Blue v2.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x404EED-Discord Blue v2.aucolor new file mode 100755 index 0000000..c142a2f --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x404EED-Discord Blue v2.aucolor @@ -0,0 +1 @@ +0x404EED \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0x4267B2-Facebook Classic Blue.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x4267B2-Facebook Classic Blue.aucolor new file mode 100755 index 0000000..e79e6a5 --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x4267B2-Facebook Classic Blue.aucolor @@ -0,0 +1 @@ +0x4267B2 \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0x4285F4-Google Blue.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x4285F4-Google Blue.aucolor new file mode 100755 index 0000000..a1f37d3 --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x4285F4-Google Blue.aucolor @@ -0,0 +1 @@ +0x4285F4 \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0x4ACBE1-Ice.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x4ACBE1-Ice.aucolor new file mode 100755 index 0000000..b5e47bf --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x4ACBE1-Ice.aucolor @@ -0,0 +1 @@ +0x4ACBE1 \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0x5865F2-Discord Blue v1.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x5865F2-Discord Blue v1.aucolor new file mode 100755 index 0000000..4f141a0 --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x5865F2-Discord Blue v1.aucolor @@ -0,0 +1 @@ +0x5865F2 \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0x784018-Espresso.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x784018-Espresso.aucolor new file mode 100755 index 0000000..11e93ed --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x784018-Espresso.aucolor @@ -0,0 +1 @@ +0x784018 \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0x99AAB5-Discord Gray.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x99AAB5-Discord Gray.aucolor new file mode 100755 index 0000000..92f4e62 --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0x99AAB5-Discord Gray.aucolor @@ -0,0 +1 @@ +0x99AAB5 \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0xACCCAC-Mint Circle.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0xACCCAC-Mint Circle.aucolor new file mode 100755 index 0000000..302d7c4 --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0xACCCAC-Mint Circle.aucolor @@ -0,0 +1 @@ +0xACCCAC \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0xC219BF-Magenta.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0xC219BF-Magenta.aucolor new file mode 100755 index 0000000..698b3f4 --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0xC219BF-Magenta.aucolor @@ -0,0 +1 @@ +0xC219BF \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0xE3CCBA-Sand.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0xE3CCBA-Sand.aucolor new file mode 100755 index 0000000..a258690 --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0xE3CCBA-Sand.aucolor @@ -0,0 +1 @@ +0xE3CCBA \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0xEA4335-Google Red.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0xEA4335-Google Red.aucolor new file mode 100755 index 0000000..c13146a --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0xEA4335-Google Red.aucolor @@ -0,0 +1 @@ +0xEA4335 \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0xFBBC05-Google Yellow.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0xFBBC05-Google Yellow.aucolor new file mode 100755 index 0000000..a9fb53f --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0xFBBC05-Google Yellow.aucolor @@ -0,0 +1 @@ +0xFBBC05 \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0xFEF000-Microsoft Yellow.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0xFEF000-Microsoft Yellow.aucolor new file mode 100755 index 0000000..042cfcb --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0xFEF000-Microsoft Yellow.aucolor @@ -0,0 +1 @@ +0xFEF000 \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0xFF06FF-Bright Pink.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0xFF06FF-Bright Pink.aucolor new file mode 100755 index 0000000..36f3c9e --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0xFF06FF-Bright Pink.aucolor @@ -0,0 +1 @@ +0xFF06FF \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0xFFFFFF-Full White.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0xFFFFFF-Full White.aucolor new file mode 100755 index 0000000..8eec672 --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0xFFFFFF-Full White.aucolor @@ -0,0 +1 @@ +0xFFFFFF \ No newline at end of file diff --git a/Color Picker/FixedColors/Color Base (AutoIT Version)/0xe49326-Buttercup.aucolor b/Color Picker/FixedColors/Color Base (AutoIT Version)/0xe49326-Buttercup.aucolor new file mode 100755 index 0000000..cefc8c0 --- /dev/null +++ b/Color Picker/FixedColors/Color Base (AutoIT Version)/0xe49326-Buttercup.aucolor @@ -0,0 +1 @@ +0xe49326 \ No newline at end of file diff --git a/Color Picker/FixedColors/ColorsLocation_AutoIT.ini b/Color Picker/FixedColors/ColorsLocation_AutoIT.ini new file mode 100755 index 0000000..dbd5f4a --- /dev/null +++ b/Color Picker/FixedColors/ColorsLocation_AutoIT.ini @@ -0,0 +1,2 @@ +[Colors Location] +Dir=C:\Users\Tyleo\OneDrive\Tyleo\Dev\Color Picker\FixedColors\Color Base (AutoIT Version) diff --git a/Color Picker/FixedColors/HEXColorPicker_Unified_x64.exe b/Color Picker/FixedColors/HEXColorPicker_Unified_x64.exe new file mode 100755 index 0000000..f920d83 Binary files /dev/null and b/Color Picker/FixedColors/HEXColorPicker_Unified_x64.exe differ diff --git a/Color Picker/MetroGUI-UDF/MetroGUI_UDF.au3 b/Color Picker/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/Color Picker/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/Color Picker/MetroGUI-UDF/MetroThemes.au3 b/Color Picker/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/Color Picker/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/Color Picker/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/Color Picker/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/Color Picker/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/Color Picker/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/Color Picker/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/Color Picker/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/Color Picker/MetroGUI-UDF/_GUIDisable.au3 b/Color Picker/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/Color Picker/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/Color Picker/TyleoAboutMe.au3 b/Color Picker/TyleoAboutMe.au3 new file mode 100755 index 0000000..75ff526 --- /dev/null +++ b/Color Picker/TyleoAboutMe.au3 @@ -0,0 +1,10 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/DNSIP Flush Manager/DNSIP Flush Manager.au3 b/DNSIP Flush Manager/DNSIP Flush Manager.au3 new file mode 100755 index 0000000..a1d9467 --- /dev/null +++ b/DNSIP Flush Manager/DNSIP Flush Manager.au3 @@ -0,0 +1,50 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Res_Comment=DNS IP Flush Manager +#AutoIt3Wrapper_Res_Description=DNS IP Flush Manager +#AutoIt3Wrapper_Res_Fileversion=0.0.0.3 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=DNS IP Flush Manager +#AutoIt3Wrapper_Res_ProductVersion=0.0.0.1 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + +GetSoftDetails(@AutoItExe,"DEV") + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +#include +#include +#include +#Region ### START Koda GUI section ### Form= +Global $Form1 = GUICreate($CurrentName & " " & $CurrentVersion, 438, 165, 275, 200) +Global $Button1 = GUICtrlCreateButton("Button1", 8, 0, 425, 33) +Global $Button2 = GUICtrlCreateButton("Button2", 8, 32, 425, 33) +Global $Button3 = GUICtrlCreateButton("Button3", 8, 64, 425, 33) +Global $Button4 = GUICtrlCreateButton("Button4", 8, 96, 425, 33) +Global $About = GUICtrlCreateButton("About this software", 8, 128, 425, 33) +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + Case $About + TyleoAbout($CurrentName & " " & $CurrentVersion & @CRLF & "Base Ver : " & $CurrentBaseVersion) + + EndSwitch +WEnd diff --git a/DNSIP Flush Manager/DNSIP Flush Manager.exe b/DNSIP Flush Manager/DNSIP Flush Manager.exe new file mode 100755 index 0000000..91bc738 Binary files /dev/null and b/DNSIP Flush Manager/DNSIP Flush Manager.exe differ diff --git a/DNSIP Flush Manager/Extensions.au3 b/DNSIP Flush Manager/Extensions.au3 new file mode 100755 index 0000000..4c3ee19 --- /dev/null +++ b/DNSIP Flush Manager/Extensions.au3 @@ -0,0 +1,34 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +; Color Accent +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +; Software Base Details +Func GetSoftDetails($Exe,$Stage) + Global $CurrentVersion,$CurrentName,$CurrentBaseVersion + $CurrentVersion = FileGetVersion($Exe,$FV_FILEVERSION) + $CurrentBaseVersion = FileGetVersion($Exe,$FV_PRODUCTVERSION) + $CurrentName = FileGetVersion($Exe,$FV_PRODUCTNAME) + if $Stage = "BETA" Then + $CurrentVersion = $CurrentVersion & "-beta" + Elseif $Stage = "RELEASE" or $Stage = "STABLE" Then + $CurrentVersion = $CurrentVersion & "-rel" + Else + $CurrentVersion = $CurrentVersion & "-dev" + EndIf + Return True +EndFunc + +; About Us +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/DNSIP Flush Manager/MetroGUI-UDF/MetroGUI_UDF.au3 b/DNSIP Flush Manager/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/DNSIP Flush Manager/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/DNSIP Flush Manager/MetroGUI-UDF/MetroThemes.au3 b/DNSIP Flush Manager/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/DNSIP Flush Manager/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/DNSIP Flush Manager/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/DNSIP Flush Manager/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/DNSIP Flush Manager/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/DNSIP Flush Manager/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/DNSIP Flush Manager/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/DNSIP Flush Manager/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/DNSIP Flush Manager/MetroGUI-UDF/_GUIDisable.au3 b/DNSIP Flush Manager/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/DNSIP Flush Manager/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/DNSIP Flush Manager/Releases/.media b/DNSIP Flush Manager/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/DNSIP Flush Manager/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) + diff --git a/EPOW-Deployable/Install Epow (Normal Mode).exe b/EPOW-Deployable/Install Epow (Normal Mode).exe new file mode 100755 index 0000000..6d26db9 Binary files /dev/null and b/EPOW-Deployable/Install Epow (Normal Mode).exe differ diff --git a/EPOW-Deployable/Install Epow (Special Mode).exe b/EPOW-Deployable/Install Epow (Special Mode).exe new file mode 100755 index 0000000..df80c55 Binary files /dev/null and b/EPOW-Deployable/Install Epow (Special Mode).exe differ diff --git a/EPOW-Deployable/Install_Epow.au3 b/EPOW-Deployable/Install_Epow.au3 new file mode 100755 index 0000000..6691012 --- /dev/null +++ b/EPOW-Deployable/Install_Epow.au3 @@ -0,0 +1,57 @@ +#include +#include +#include +#include +#AutoIt3Wrapper_Icon=PMenu.ico +#AutoIt3Wrapper_Outfile_x64=Install Epow (Normal Mode).exe +#AutoIt3Wrapper_Res_Comment=Epow Setup +#AutoIt3Wrapper_Res_Description=Epow Setup +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_ProductName=Epow Setup +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#AutoIt3Wrapper_Res_Language=1033 +#RequireAdmin + +$epow_data = @ScriptDir & "\epow_data" +if Not FileExists($epow_data) Then + MsgBox(0+16,"ERROR","No " & $epow_data & " folder detected !!") + Exit(1) +Endif + +; SETUP +$epow_setupdir = @ProgramFilesDir & "\EPOW By Tyleo" +$epow_desktop = @DesktopCommonDir +$epow_startmenu = @StartMenuCommonDir + +#Region ### START Koda GUI section ### Form= +Global $Form1 = GUICreate("", 155, 78, 475, 344) +Global $Label1 = GUICtrlCreateLabel("Epow - Power Menu Toolset", 8, 8, 138, 17) +Global $Install = GUICtrlCreateButton("INSTALL IT !", 8, 40, 137, 25) +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + Case $Install + GUICtrlSetState($Install, $GUI_DISABLE) + GUICtrlSetData($Install,"WORKING") + DirCreate($epow_setupdir) + FileCopy($epow_data & "\*",$epow_setupdir) + FileCreateShortcut($epow_setupdir & "\Lock.exe",$epow_startmenu & "\Lock") + FileCreateShortcut($epow_setupdir & "\Lock.exe",$epow_desktop & "\Lock") + FileCreateShortcut($epow_setupdir & "\Restart.exe",$epow_startmenu & "\Restart") + FileCreateShortcut($epow_setupdir & "\Restart.exe",$epow_desktop & "\Restart") + FileCreateShortcut($epow_setupdir & "\ShutdownNow.exe",$epow_startmenu & "\Shutdown Now") + FileCreateShortcut($epow_setupdir & "\ShutdownNow.exe",$epow_desktop & "\Shutdown Now") + Sleep(450) + GUICtrlSetData($Install,"DONE !") + Sleep(800) + Exit(0) + EndSwitch +WEnd diff --git a/EPOW-Deployable/Install_Epow_Spec.au3 b/EPOW-Deployable/Install_Epow_Spec.au3 new file mode 100755 index 0000000..5b907ae --- /dev/null +++ b/EPOW-Deployable/Install_Epow_Spec.au3 @@ -0,0 +1,65 @@ +#RequireAdmin +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=PMenu.ico +#AutoIt3Wrapper_Outfile_x64=Install Epow (Special Mode).exe +#AutoIt3Wrapper_Res_Comment=Epow Setup +#AutoIt3Wrapper_Res_Description=Epow Setup +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_ProductName=Epow Setup +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#AutoIt3Wrapper_Res_Language=1033 +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +#include +#include +#include +#include + + +$epow_data = @ScriptDir & "\epow_data" +if Not FileExists($epow_data) Then + MsgBox(0+16,"ERROR","No " & $epow_data & " folder detected !!") + Exit(1) +Endif + +; SETUP +$epow_setupdir = @ProgramFilesDir & "\EPOW By Tyleo" +$epow_desktop = @DesktopCommonDir +$epow_startmenu = @StartMenuCommonDir + +#Region ### START Koda GUI section ### Form= +Global $Form1 = GUICreate("", 155, 78, 475, 344) +Global $Label1 = GUICtrlCreateLabel("Epow - Power Menu Toolset", 8, 8, 138, 17) +Global $Install = GUICtrlCreateButton("INSTALL IT !", 8, 40, 137, 25) +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + Case $Install + GUICtrlSetState($Install, $GUI_DISABLE) + GUICtrlSetData($Install,"WORKING") + DirCreate($epow_setupdir) + FileCopy($epow_data & "\*",$epow_setupdir) + FileCopy($epow_data & "\Specials\*",$epow_setupdir) + FileCreateShortcut($epow_setupdir & "\Lock.exe",$epow_startmenu & "\Lock") + FileCreateShortcut($epow_setupdir & "\Lock.exe",$epow_desktop & "\Lock") + FileCreateShortcut($epow_setupdir & "\Restart.exe",$epow_startmenu & "\Restart") + FileCreateShortcut($epow_setupdir & "\Restart.exe",$epow_desktop & "\Restart") + FileCreateShortcut($epow_setupdir & "\ShutdownNow.exe",$epow_startmenu & "\Shutdown Now") + FileCreateShortcut($epow_setupdir & "\ShutdownNow.exe",$epow_desktop & "\Shutdown Now") + FileCreateShortcut($epow_setupdir & "\Firmware.exe",$epow_startmenu & "\Firmware") + FileCreateShortcut($epow_setupdir & "\Firmware.exe",$epow_desktop & "\Firmware") + FileCreateShortcut($epow_setupdir & "\LockNoUI.exe",$epow_startmenu & "\Lock Now") + FileCreateShortcut($epow_setupdir & "\LockNoUI.exe",$epow_desktop & "\Lock Now") + Sleep(450) + GUICtrlSetData($Install,"DONE !") + Sleep(800) + Exit(0) + EndSwitch +WEnd diff --git a/EPOW-Deployable/PMenu.ico b/EPOW-Deployable/PMenu.ico new file mode 100755 index 0000000..3d1e5ab Binary files /dev/null and b/EPOW-Deployable/PMenu.ico differ diff --git a/EPOW-Deployable/epow_data/Lock.exe b/EPOW-Deployable/epow_data/Lock.exe new file mode 100755 index 0000000..d4f38d3 Binary files /dev/null and b/EPOW-Deployable/epow_data/Lock.exe differ diff --git a/EPOW-Deployable/epow_data/Restart.exe b/EPOW-Deployable/epow_data/Restart.exe new file mode 100755 index 0000000..7a860b8 Binary files /dev/null and b/EPOW-Deployable/epow_data/Restart.exe differ diff --git a/EPOW-Deployable/epow_data/ShutdownNow.exe b/EPOW-Deployable/epow_data/ShutdownNow.exe new file mode 100755 index 0000000..fa1f63d Binary files /dev/null and b/EPOW-Deployable/epow_data/ShutdownNow.exe differ diff --git a/EPOW-Deployable/epow_data/Specials/Firmware.exe b/EPOW-Deployable/epow_data/Specials/Firmware.exe new file mode 100755 index 0000000..517fc86 Binary files /dev/null and b/EPOW-Deployable/epow_data/Specials/Firmware.exe differ diff --git a/EPOW-Deployable/epow_data/Specials/LockNoUI.exe b/EPOW-Deployable/epow_data/Specials/LockNoUI.exe new file mode 100755 index 0000000..bd173ab Binary files /dev/null and b/EPOW-Deployable/epow_data/Specials/LockNoUI.exe differ diff --git a/EPOW/Firmware.au3 b/EPOW/Firmware.au3 new file mode 100755 index 0000000..9c9dec4 --- /dev/null +++ b/EPOW/Firmware.au3 @@ -0,0 +1,19 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=Firmware.ico +#AutoIt3Wrapper_Outfile_x64=Releases\Specials\Firmware.exe +#AutoIt3Wrapper_Res_Comment=Epow Toolset Part +#AutoIt3Wrapper_Res_Description=Epow Toolset Part +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_ProductName=Epow Toolset Part +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#AutoIt3Wrapper_Res_Language=1033 +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +$Confirm = MsgBox(4,"Transfert vers le BIOS/UEFI","Cliquez sur Oui pour redémarrer sur le BIOS/UEFI") +; MsgBox(0,"ANSWER",$Confirm) + +If $Confirm = "6" Then + Run("shutdown -fw -r -t 00", "", @SW_HIDE) +EndIf \ No newline at end of file diff --git a/EPOW/Firmware.ico b/EPOW/Firmware.ico new file mode 100755 index 0000000..79e9efa Binary files /dev/null and b/EPOW/Firmware.ico differ diff --git a/EPOW/Lock.au3 b/EPOW/Lock.au3 new file mode 100755 index 0000000..62c57d1 --- /dev/null +++ b/EPOW/Lock.au3 @@ -0,0 +1,19 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=Lock.ico +#AutoIt3Wrapper_Outfile_x64=Releases\Lock.exe +#AutoIt3Wrapper_Res_Comment=Epow Toolset Part +#AutoIt3Wrapper_Res_Description=Epow Toolset Part +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_ProductName=Epow Toolset Part +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#AutoIt3Wrapper_Res_Language=1033 +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +$Confirm = MsgBox(4,"Vérouillage","Cliquez sur Oui pour vérouiller l'ordinateur") +; MsgBox(0,"ANSWER",$Confirm) + +If $Confirm = "6" Then + Run("Rundll32.exe user32.dll,LockWorkStation", "", @SW_HIDE) +EndIf \ No newline at end of file diff --git a/EPOW/Lock.ico b/EPOW/Lock.ico new file mode 100755 index 0000000..91f09cf Binary files /dev/null and b/EPOW/Lock.ico differ diff --git a/EPOW/Lock_NoUI.au3 b/EPOW/Lock_NoUI.au3 new file mode 100755 index 0000000..6cce700 --- /dev/null +++ b/EPOW/Lock_NoUI.au3 @@ -0,0 +1,14 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=Lock.ico +#AutoIt3Wrapper_Outfile_x64=Releases\Specials\LockNoUI.exe +#AutoIt3Wrapper_Res_Comment=Epow Toolset Part +#AutoIt3Wrapper_Res_Description=Epow Toolset Part +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_ProductName=Epow Toolset Part +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#AutoIt3Wrapper_Res_Language=1033 +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +Run("Rundll32.exe user32.dll,LockWorkStation", "", @SW_HIDE) \ No newline at end of file diff --git a/EPOW/Releases/Lock.exe b/EPOW/Releases/Lock.exe new file mode 100755 index 0000000..d4f38d3 Binary files /dev/null and b/EPOW/Releases/Lock.exe differ diff --git a/EPOW/Releases/Restart.exe b/EPOW/Releases/Restart.exe new file mode 100755 index 0000000..b29ddc6 Binary files /dev/null and b/EPOW/Releases/Restart.exe differ diff --git a/EPOW/Releases/ShutdownNow.exe b/EPOW/Releases/ShutdownNow.exe new file mode 100755 index 0000000..fa1f63d Binary files /dev/null and b/EPOW/Releases/ShutdownNow.exe differ diff --git a/EPOW/Releases/Specials/Firmware.exe b/EPOW/Releases/Specials/Firmware.exe new file mode 100755 index 0000000..3ae188c Binary files /dev/null and b/EPOW/Releases/Specials/Firmware.exe differ diff --git a/EPOW/Releases/Specials/LockNoUI.exe b/EPOW/Releases/Specials/LockNoUI.exe new file mode 100755 index 0000000..bd173ab Binary files /dev/null and b/EPOW/Releases/Specials/LockNoUI.exe differ diff --git a/EPOW/Restart.au3 b/EPOW/Restart.au3 new file mode 100755 index 0000000..2d1a6ec --- /dev/null +++ b/EPOW/Restart.au3 @@ -0,0 +1,19 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=Restart.ico +#AutoIt3Wrapper_Outfile_x64=Releases\Restart.exe +#AutoIt3Wrapper_Res_Comment=Epow Toolset Part +#AutoIt3Wrapper_Res_Description=Epow Toolset Part +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_ProductName=Epow Toolset Part +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#AutoIt3Wrapper_Res_Language=1033 +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +$Confirm = MsgBox(4,"Redémarrage","Cliquez sur Oui pour redémarrer l'ordinateur") +; MsgBox(0,"ANSWER",$Confirm) + +If $Confirm = "6" Then + Run("shutdown -r -t 00", "", @SW_HIDE) +EndIf \ No newline at end of file diff --git a/EPOW/Restart.ico b/EPOW/Restart.ico new file mode 100755 index 0000000..d769787 Binary files /dev/null and b/EPOW/Restart.ico differ diff --git a/EPOW/Shutdown.au3 b/EPOW/Shutdown.au3 new file mode 100755 index 0000000..a20f223 --- /dev/null +++ b/EPOW/Shutdown.au3 @@ -0,0 +1,19 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=Shutdown.ico +#AutoIt3Wrapper_Outfile_x64=Releases\ShutdownNow.exe +#AutoIt3Wrapper_Res_Comment=Epow Toolset Part +#AutoIt3Wrapper_Res_Description=Epow Toolset Part +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_ProductName=Epow Toolset Part +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#AutoIt3Wrapper_Res_Language=1033 +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +$Confirm = MsgBox(4,"Arrêt","Cliquez sur Oui pour arrêter l'ordinateur") +; MsgBox(0,"ANSWER",$Confirm) + +If $Confirm = "6" Then + Run("shutdown -f -p", "", @SW_HIDE) +EndIf \ No newline at end of file diff --git a/EPOW/Shutdown.ico b/EPOW/Shutdown.ico new file mode 100755 index 0000000..9decaf7 Binary files /dev/null and b/EPOW/Shutdown.ico differ diff --git a/IODD Manager Pack/IODD Manager Pack.au3 b/IODD Manager Pack/IODD Manager Pack.au3 new file mode 100755 index 0000000..5aad4a4 --- /dev/null +++ b/IODD Manager Pack/IODD Manager Pack.au3 @@ -0,0 +1,46 @@ + +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "TyleoAboutMe.au3" + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +#include +#include +#include +#include +#include +#Region ### START Koda GUI section ### Form= +Global $Form1 = GUICreate("IODD Man Pack", 370, 326, 190, 135) +Global $Label1 = GUICtrlCreateLabel("IODD Management Pack", 8, 0, 353, 49) +GUICtrlSetFont(-1, 24, 400, 0, "Segoe UI") +Global $List1 = GUICtrlCreateList("", 0, 48, 369, 236, -1, 0) +Global $Button1 = GUICtrlCreateButton("LANCER", 8, 288, 353, 33) +GUICtrlSetFont(-1, 14, 400, 0, "Segoe UI") +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + + EndSwitch +WEnd diff --git a/IODD Manager Pack/MetroGUI-UDF/MetroGUI_UDF.au3 b/IODD Manager Pack/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/IODD Manager Pack/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/IODD Manager Pack/MetroGUI-UDF/MetroThemes.au3 b/IODD Manager Pack/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/IODD Manager Pack/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/IODD Manager Pack/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/IODD Manager Pack/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/IODD Manager Pack/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/IODD Manager Pack/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/IODD Manager Pack/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/IODD Manager Pack/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/IODD Manager Pack/MetroGUI-UDF/_GUIDisable.au3 b/IODD Manager Pack/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/IODD Manager Pack/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/IODD Manager Pack/Releases/.media b/IODD Manager Pack/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/IODD Manager Pack/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) + diff --git a/IODD Manager Pack/TyleoAboutMe.au3 b/IODD Manager Pack/TyleoAboutMe.au3 new file mode 100755 index 0000000..75ff526 --- /dev/null +++ b/IODD Manager Pack/TyleoAboutMe.au3 @@ -0,0 +1,10 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/IODD Manager Pack/WinAccent.au3 b/IODD Manager Pack/WinAccent.au3 new file mode 100755 index 0000000..9bd9398 --- /dev/null +++ b/IODD Manager Pack/WinAccent.au3 @@ -0,0 +1,17 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. + +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor \ No newline at end of file diff --git a/IT-Tools-XR/.filerun.versioning/Extensions.au3/1/data b/IT-Tools-XR/.filerun.versioning/Extensions.au3/1/data new file mode 100755 index 0000000..276228e --- /dev/null +++ b/IT-Tools-XR/.filerun.versioning/Extensions.au3/1/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647077165;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/IT-Tools-XR/.filerun.versioning/Extensions.au3/1/file b/IT-Tools-XR/.filerun.versioning/Extensions.au3/1/file new file mode 100755 index 0000000..4c3ee19 --- /dev/null +++ b/IT-Tools-XR/.filerun.versioning/Extensions.au3/1/file @@ -0,0 +1,34 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +; Color Accent +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +; Software Base Details +Func GetSoftDetails($Exe,$Stage) + Global $CurrentVersion,$CurrentName,$CurrentBaseVersion + $CurrentVersion = FileGetVersion($Exe,$FV_FILEVERSION) + $CurrentBaseVersion = FileGetVersion($Exe,$FV_PRODUCTVERSION) + $CurrentName = FileGetVersion($Exe,$FV_PRODUCTNAME) + if $Stage = "BETA" Then + $CurrentVersion = $CurrentVersion & "-beta" + Elseif $Stage = "RELEASE" or $Stage = "STABLE" Then + $CurrentVersion = $CurrentVersion & "-rel" + Else + $CurrentVersion = $CurrentVersion & "-dev" + EndIf + Return True +EndFunc + +; About Us +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/IT-Tools-XR/.filerun.versioning/Extensions.au3/2/data b/IT-Tools-XR/.filerun.versioning/Extensions.au3/2/data new file mode 100755 index 0000000..99801f8 --- /dev/null +++ b/IT-Tools-XR/.filerun.versioning/Extensions.au3/2/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647077245;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/IT-Tools-XR/.filerun.versioning/Extensions.au3/2/file b/IT-Tools-XR/.filerun.versioning/Extensions.au3/2/file new file mode 100755 index 0000000..10fd066 --- /dev/null +++ b/IT-Tools-XR/.filerun.versioning/Extensions.au3/2/file @@ -0,0 +1,34 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +; Color Accent +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +; Software Base Details +Func GetSoftDetails($Exe,$Stage) + Global $CurrentVersion,$CurrentName,$CurrentBaseVersion + $CurrentVersion = FileGetVersion($Exe,$FV_FILEVERSION) + $CurrentBaseVersion = FileGetVersion($Exe,$FV_PRODUCTVERSION) + $CurrentName = FileGetVersion($Exe,$FV_PRODUCTNAME) + if $Stage = "BETA" Then + $CurrentVersion = $CurrentVersion & "-beta" + Elseif $Stage = "RELEASE" or $Stage = "STABLE" Then + $CurrentVersion = $CurrentVersion & "-rel" + Else + $CurrentVersion = $CurrentVersion & "-dev" + EndIf + Return True +EndFunc + +; About Us +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2022" & @CRLF & " " & @CRLF & "MAKE IT HAPPENING" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/IT-Tools-XR/Extensions.au3 b/IT-Tools-XR/Extensions.au3 new file mode 100755 index 0000000..e4f06b5 --- /dev/null +++ b/IT-Tools-XR/Extensions.au3 @@ -0,0 +1,48 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +; Color Accent +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +; Color Accent Refresh +Func ColorReload() +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor +EndFunc + +; Software Base Details +Func GetSoftDetails($Exe,$Stage) + Global $CurrentVersion,$CurrentName,$CurrentBaseVersion + $CurrentVersion = FileGetVersion($Exe,$FV_FILEVERSION) + $CurrentBaseVersion = FileGetVersion($Exe,$FV_PRODUCTVERSION) + $CurrentName = FileGetVersion($Exe,$FV_PRODUCTNAME) + if $Stage = "BETA" Then + $CurrentVersion = $CurrentVersion & "-beta" + Elseif $Stage = "RELEASE" or $Stage = "STABLE" Then + $CurrentVersion = $CurrentVersion & "-rel" + Else + $CurrentVersion = $CurrentVersion & "-dev" + EndIf + Return True +EndFunc + +; About Us +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2022" & @CRLF & " " & @CRLF & "MAKE IT HAPPENING" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "support@tyleodev.fr",400,15) + Return True +EndFunc + +; Main Website Open Handle +Func TyleoWebsite() + ShellExecute("https://tyleodev.fr") +EndFunc \ No newline at end of file diff --git a/IT-Tools-XR/IT-Tools-XR.au3 b/IT-Tools-XR/IT-Tools-XR.au3 new file mode 100755 index 0000000..1ab24c7 --- /dev/null +++ b/IT-Tools-XR/IT-Tools-XR.au3 @@ -0,0 +1,25 @@ + +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + +GetSoftDetails(@AutoItExe,"DEV") + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + diff --git a/IT-Tools-XR/MetroGUI-UDF/MetroGUI_UDF.au3 b/IT-Tools-XR/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/IT-Tools-XR/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/IT-Tools-XR/MetroGUI-UDF/MetroThemes.au3 b/IT-Tools-XR/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/IT-Tools-XR/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/IT-Tools-XR/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/IT-Tools-XR/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/IT-Tools-XR/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/IT-Tools-XR/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/IT-Tools-XR/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/IT-Tools-XR/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/IT-Tools-XR/MetroGUI-UDF/_GUIDisable.au3 b/IT-Tools-XR/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/IT-Tools-XR/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/IT-Tools-XR/Projet.kxf b/IT-Tools-XR/Projet.kxf new file mode 100755 index 0000000..e8a2629 --- /dev/null +++ b/IT-Tools-XR/Projet.kxf @@ -0,0 +1,229 @@ + + + + 192 + 154 + 633 + 292 + Form1 + clBtnFace + DEFAULT_CHARSET + clWindowText + -13 + Segoe UI + + Menu1 + False + True + -1798701056 + 256 + 1.04 + False + False + False + False + -1 + 1 + 0 + 1 + + 96 + 15 + + + + + 586 + 56 + 28 + 28 + Owner + MainMenu1 + + + + + + 5 + 9 + 70 + 23 + Utilisateur + DEFAULT_CHARSET + clWindowText + -16 + Segoe UI + + False + 0 + False + 1342308608 + 0 + + + + + + + 5 + 32 + 41 + 23 + Poste + DEFAULT_CHARSET + clWindowText + -16 + Segoe UI + + False + 1 + False + 1342308608 + 0 + + + + + + + 258 + 66 + 100 + 19 + Descriptif Rapide + 2 + False + 1342308609 + 0 + + + + + + + 81 + 7 + 418 + 23 + 3 + Input1 + 1342374016 + 512 + DockHeight + + + + + + 500 + 7 + 109 + 23 + 4 + Input1 + 1342374016 + 512 + DockHeight + + + + + + 50 + 32 + 294 + 23 + 5 + Input3 + 1342374016 + 512 + DockHeight + + + + + + 1 + 86 + 615 + 146 + + +
  • Edit1
  • +
    +
    + 6 + 1345523908 + 512 + +
    + +
    + + + 372 + 33 + 239 + 23 + 7 + Input3 + 1342374016 + 512 + DockHeight + + + + + + 346 + 34 + 25 + 23 + Tel. + DEFAULT_CHARSET + clWindowText + -16 + Segoe UI + + False + 8 + False + 1342308608 + 0 + + + + + + + + + + MenuItem2 + + + + + MenuItem4 + + + + + + + + MenuItem1 + + + + + MenuItem3 + + + + + + + +
    +
    \ No newline at end of file diff --git a/IT-Tools-XR/README.md b/IT-Tools-XR/README.md new file mode 100755 index 0000000..ce6d680 --- /dev/null +++ b/IT-Tools-XR/README.md @@ -0,0 +1 @@ +Logiciel Tyleo Créé avec CNP \ No newline at end of file diff --git a/IT-Tools-XR/Releases/.media b/IT-Tools-XR/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/IT-Tools-XR/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) + diff --git a/Leo Notes/Extensions.au3 b/Leo Notes/Extensions.au3 new file mode 100755 index 0000000..e4f06b5 --- /dev/null +++ b/Leo Notes/Extensions.au3 @@ -0,0 +1,48 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +; Color Accent +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +; Color Accent Refresh +Func ColorReload() +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor +EndFunc + +; Software Base Details +Func GetSoftDetails($Exe,$Stage) + Global $CurrentVersion,$CurrentName,$CurrentBaseVersion + $CurrentVersion = FileGetVersion($Exe,$FV_FILEVERSION) + $CurrentBaseVersion = FileGetVersion($Exe,$FV_PRODUCTVERSION) + $CurrentName = FileGetVersion($Exe,$FV_PRODUCTNAME) + if $Stage = "BETA" Then + $CurrentVersion = $CurrentVersion & "-beta" + Elseif $Stage = "RELEASE" or $Stage = "STABLE" Then + $CurrentVersion = $CurrentVersion & "-rel" + Else + $CurrentVersion = $CurrentVersion & "-dev" + EndIf + Return True +EndFunc + +; About Us +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2022" & @CRLF & " " & @CRLF & "MAKE IT HAPPENING" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "support@tyleodev.fr",400,15) + Return True +EndFunc + +; Main Website Open Handle +Func TyleoWebsite() + ShellExecute("https://tyleodev.fr") +EndFunc \ No newline at end of file diff --git a/Leo Notes/Form1.kxf b/Leo Notes/Form1.kxf new file mode 100755 index 0000000..8e5356e --- /dev/null +++ b/Leo Notes/Form1.kxf @@ -0,0 +1,388 @@ + + + + 274 + 128 + 481 + 708 + Form1 + clBtnFace + DEFAULT_CHARSET + clWindowText + -11 + MS Sans Serif + + Menu1 + False + True + -1798701056 + 256 + 1.04 + False + False + False + False + -1 + 1 + 0 + 1 + + 96 + 13 + + + + + 400 + 0 + 28 + 28 + Owner + MainMenu1 + + + + + + 8 + 8 + 449 + 41 + 1342308359 + 0 + Title + 0 + + + + + + 8 + 16 + 433 + 21 + 0 + Input1 + 1342374016 + 512 + DockHeight + + + + + + + + 8 + 56 + 449 + 313 + 1342308359 + 0 + Note Content + 1 + + + + + + 8 + 16 + 433 + 289 + + +
  • Edit1
  • +
    +
    + 0 + 1345523908 + 512 + +
    + +
    +
    +
    + + + 8 + 376 + 89 + 265 + 1342308359 + 0 + Management + 2 + + + + + + 8 + 16 + 73 + 17 + Button1 + 0 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 32 + 73 + 17 + Button2 + 1 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 48 + 73 + 17 + Button3 + 2 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 64 + 73 + 17 + Button4 + 3 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 80 + 73 + 17 + Button5 + 4 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 96 + 73 + 17 + Button6 + 5 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 112 + 73 + 17 + Button7 + 6 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 128 + 73 + 17 + Button8 + 7 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 144 + 73 + 17 + Button9 + 8 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 160 + 73 + 17 + Button10 + 9 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 176 + 73 + 17 + Button11 + 10 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 192 + 73 + 17 + Button12 + 11 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 208 + 73 + 17 + Button13 + 12 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 224 + 73 + 17 + Button14 + 13 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 240 + 73 + 17 + Button15 + 14 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + + + 104 + 376 + 353 + 265 + 1342308359 + 0 + Note Database + 3 + + + + + + 8 + 16 + 337 + 240 + 13 + 0 + 1352859651 + 512 + + + + + + + + + + + + MenuItem1 + + + + + +
    +
    \ No newline at end of file diff --git a/Leo Notes/Form1.kxf.bak b/Leo Notes/Form1.kxf.bak new file mode 100755 index 0000000..527683e --- /dev/null +++ b/Leo Notes/Form1.kxf.bak @@ -0,0 +1,381 @@ + + + + 339 + 113 + 481 + 703 + Form1 + clBtnFace + DEFAULT_CHARSET + clWindowText + -11 + MS Sans Serif + + Menu1 + False + True + -1798701056 + 256 + 1.04 + False + False + False + False + -1 + 1 + 0 + 1 + + 96 + 13 + + + + + 400 + 0 + 28 + 28 + Owner + MainMenu1 + + + + + + 8 + 24 + 449 + 41 + 1342308359 + 0 + Title + 0 + + + + + + 8 + 16 + 433 + 21 + 0 + Input1 + 1342374016 + 512 + DockHeight + + + + + + + + 8 + 72 + 449 + 313 + 1342308359 + 0 + Note Content + 1 + + + + + + 8 + 16 + 433 + 289 + + +
  • Edit1
  • +
    +
    + 0 + 1345523908 + 512 + +
    + +
    +
    +
    + + + 8 + 392 + 89 + 265 + 1342308359 + 0 + Management + 2 + + + + + + 8 + 16 + 73 + 17 + Button1 + 0 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 32 + 73 + 17 + Button2 + 1 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 48 + 73 + 17 + Button3 + 2 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 64 + 73 + 17 + Button4 + 3 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 80 + 73 + 17 + Button5 + 4 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 96 + 73 + 17 + Button6 + 5 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 112 + 73 + 17 + Button7 + 6 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 128 + 73 + 17 + Button8 + 7 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 144 + 73 + 17 + Button9 + 8 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 160 + 73 + 17 + Button10 + 9 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 176 + 73 + 17 + Button11 + 10 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 192 + 73 + 17 + Button12 + 11 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 208 + 73 + 17 + Button13 + 12 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 224 + 73 + 17 + Button14 + 13 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 240 + 73 + 17 + Button15 + 14 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + + + 104 + 392 + 353 + 265 + 1342308359 + 0 + Note Database + 3 + + + + + + 8 + 16 + 337 + 240 + 13 + 0 + 1352859651 + 512 + + + + + + + + + + +
    +
    \ No newline at end of file diff --git a/Leo Notes/Leo Notes.au3 b/Leo Notes/Leo Notes.au3 new file mode 100755 index 0000000..313c82c --- /dev/null +++ b/Leo Notes/Leo Notes.au3 @@ -0,0 +1,447 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=Leo.ico +#AutoIt3Wrapper_Outfile_x64=..\..\Logiciels\LeoNota.exe +#AutoIt3Wrapper_Res_Comment=Manage and Create Notes, Nouvelle Génération. +#AutoIt3Wrapper_Res_Description=Manage and Create Notes, Nouvelle Génération. +#AutoIt3Wrapper_Res_Fileversion=1.0.6.5 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=Leo Nota +#AutoIt3Wrapper_Res_ProductVersion=1.0.5.2 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + + +GetSoftDetails(@AutoItExe,"BETA") + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +$ext = ".nota" + +#Region + ; Localisation par défault et configuration INI + $defaultbaseloc = @MyDocumentsDir & "\My Notes" + if FileExists($defaultbaseloc) Then + $defaultbaseloc = $defaultbaseloc + Else + DirCreate($defaultbaseloc) + DirCreate($defaultbaseloc & "\Archives") + EndIf + + + $cfgdir = @AppDataDir & "\Leo Notes" + $cfgfile = $cfgdir & "\general.cfg" + + if FileExists($cfgdir) Then + ; + Else + DirCreate($cfgdir) + EndIf + + if FileExists($cfgfile) Then + ; + Else + IniWrite($cfgfile,"configuration","fontface","Segoe UI Light") + IniWrite($cfgfile,"configuration","font color","0x000000") + IniWrite($cfgfile,"configuration","font size","10") + IniWrite($cfgfile,"configuration","font weight","400") + IniWrite($cfgfile,"configuration","background color","0xFFFFFF") + IniWrite($cfgfile,"configuration","database location",$defaultbaseloc) + EndIf +#EndRegion + +$fontface = IniRead($cfgfile,"configuration","fontface","Segoe UI Light") +$fontsize = IniRead($cfgfile,"configuration","font size","10") +$fontweight = IniRead($cfgfile,"configuration","font weight","400") +$fontcolor = IniRead($cfgfile,"configuration","font color","0x000000") +$backcolor = IniRead($cfgfile,"configuration","background color","0xFFFFFF") +$baseloc = IniRead($cfgfile,"configuration","database location",$defaultbaseloc) + + if FileExists($baseloc & "\Archived") Then + ; + Else + DirCreate($baseloc & "\Archived") + EndIf + +#include +#include +#include +#include +#include "_Zip.au3" +#include "Outlook.au3" +#include +#include +#include +#include +#Region ### START Koda GUI section ### Form=C:\Users\Tyleo\Nextcloud2\Tyleo\Dev\My NotePad\Form1.kxf +Global $GUI = GUICreate("Leo Nota v" & $CurrentVersion, 866, 670, 274, 128) +GUISetBkColor($CurrentAccent,$GUI) +GUISetFont(9.5,"","","Segoe UI Light") + +Global $Files = GUICtrlCreateMenu("Files") +Global $Files_Import = GUICtrlCreateMenu("Import",$Files) +Global $Files_Import_TXT = GUICtrlCreateMenuItem("Text File" & @TAB & "*.txt",$Files_Import) +Global $Files_Import_MD = GUICtrlCreateMenuItem("Markdown File" & @TAB & "*.md",$Files_Import) + +Global $Edit = GUICtrlCreateMenu("Edition") +Global $Edit_CopyAll = GUICtrlCreateMenuItem("Copy all to Clipboard",$Edit) +Global $Edit_PasteAppend = GUICtrlCreateMenuItem("Paste" & @TAB & "Next To Current Data",$Edit) +Global $Edit_PasteReplace = GUICtrlCreateMenuItem("Paste" & @TAB & "Replace Current Data",$Edit) + +Global $Config = GUICtrlCreateMenu("Configuration") +Global $Config_Personnalize = GUICtrlCreateMenu("Customize UI") +Global $Config_Font = GUICtrlCreateMenuItem("Change FontFace",$Config_Personnalize) +Global $Config_Fk = GUICtrlCreateMenuItem("Font Color",$Config_Personnalize) +Global $Config_Bk = GUICtrlCreateMenuItem("Background Color",$Config_Personnalize) +Global $Config_Bk_acc = GUICtrlCreateMenuItem("Accent as Background",$Config_Personnalize) +Global $Config_Loc = GUICtrlCreateMenu("Advanced",$Config) +Global $Config_ChangeDatabaseLoc = GUICtrlCreateMenuItem("Change Note Database Location" & @TAB & $baseloc,$Config_Loc) + +Global $Archive = GUICtrlCreateMenu("Archive") +Global $Archive_Open = GUICtrlCreateMenuItem("Open Archives" & @TAB & $baseloc & "\Archived",$Archive) +Global $Archive_Export = GUICtrlCreateMenuItem("Backup Archives as ZIP" & @TAB & "EXPERIMENTAL",$Archive) + +Global $Version = GUICtrlCreateMenu("Version") +Global $Version_About = GUICtrlCreateMenuItem("About",$Version) +Global $Version_Site = GUICtrlCreateMenuItem("Website" & @TAB & "tyleodev.fr",$Version) + +Global $Group1 = GUICtrlCreateGroup(" Title ", 8, 8, 849, 41) +Global $NoteTitle = GUICtrlCreateInput("", 16, 24, 833, 21) +GUICtrlSetBkColor(-1,$backcolor) +GUICtrlSetColor(-1,$fontcolor) +GUICtrlSetFont(-1, "9.5", $fontweight, "", $fontface, 2) +GUICtrlCreateGroup("", -99, -99, 1, 1) +Global $Group2 = GUICtrlCreateGroup(" Note Content ", 8, 56, 849, 313) +Global $NoteContent = GUICtrlCreateEdit("", 16, 72, 833, 289) +GUICtrlSetBkColor(-1,$backcolor) +GUICtrlSetColor(-1,$fontcolor) +GUICtrlSetFont(-1, $fontsize, $fontweight, "", $fontface, 2) +GUICtrlSetData(-1, "") +GUICtrlCreateGroup("", -99, -99, 1, 1) +Global $Group3 = GUICtrlCreateGroup(" Management ", 8, 376, 89, 265) +Global $Open = GUICtrlCreateButton("Open", 16, 392, 73, 17) +GUICtrlSetCursor(-1,0) +Global $Save = GUICtrlCreateButton("Save", 16, 408, 73, 17) +GUICtrlSetCursor(-1,0) +Global $Rename = GUICtrlCreateButton("Rename", 16, 424, 73, 17) +GUICtrlSetCursor(-1,0) +Global $Delete = GUICtrlCreateButton("Delete", 16, 440, 73, 17) +GUICtrlSetCursor(-1,0) +Global $ArchiveIt = GUICtrlCreateButton("Archive", 16, 456, 73, 17) +GUICtrlSetCursor(-1,0) +Global $ToMD = GUICtrlCreateButton("Export MD", 16, 488, 73, 17) +GUICtrlSetCursor(-1,0) +Global $ToTXT = GUICtrlCreateButton("Export TXT", 16, 504, 73, 17) +GUICtrlSetCursor(-1,0) +Global $ToRTF = GUICtrlCreateButton("Export RTF", 16, 520, 73, 17) +GUICtrlSetCursor(-1,0) +Global $ToPDF = GUICtrlCreateButton("Export PDF", 16, 536, 73, 17) +GUICtrlSetCursor(-1,0) +GUICtrlSetState(-1,$GUI_DISABLE) +Global $DBOpen = GUICtrlCreateButton("Open DB", 16, 584, 73, 17) +GUICtrlSetCursor(-1,0) +Global $DBClose = GUICtrlCreateButton("Close DB", 16, 600, 73, 17) +GUICtrlSetCursor(-1,0) +Global $DBRefresh = GUICtrlCreateButton("Refresh DB", 16, 616, 73, 17) +GUICtrlSetCursor(-1,0) +GUICtrlCreateGroup("", -99, -99, 1, 1) +Global $Group4 = GUICtrlCreateGroup(" Note Database ", 104, 376, 753, 265) +Global $NoteDB = GUICtrlCreateList("", 112, 392, 737, 240) +GUICtrlSetBkColor(-1,$backcolor) +GUICtrlSetColor(-1,$fontcolor) +GUICtrlSetFont(-1, "9.5", $fontweight, "", $fontface, 2) +GUICtrlCreateGroup("", -99, -99, 1, 1) +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +DBRefresh() +DateGet() + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + + Case $Version_Site + ShellExecute("https://tyleodev.fr") + + Case $Open + $Selected = GUICtrlRead($NoteDB) + $Opened = FileOpen($baseloc & "\" & $Selected & ".nota") + $Read = FileRead($Opened) + GUICtrlSetData($NoteContent,$Read) + GUICtrlSetData($NoteTitle,$Selected) + + Case $NoteDB + $Selected = GUICtrlRead($NoteDB) + $Opened = FileOpen($baseloc & "\" & $Selected & ".nota") + $Read = FileRead($Opened) + GUICtrlSetData($NoteContent,$Read) + GUICtrlSetData($NoteTitle,$Selected) + + Case $Save + $NoteName = GUICtrlRead($NoteTitle) + $wData = GUICtrlRead($NoteContent) + $dPool = FileOpen($baseloc & "\" & $NoteName & ".nota",2) + FileWrite($dPool,$wData) + DBRefresh() + + Case $Delete + $Selected = GUICtrlRead($NoteDB) + $Confirm = MsgBox(4,"Confirm Deletion","Confirm deletion. This action are not undoable (Secure Delete)") + if $Confirm = 6 Then + FileDelete($baseloc & "\" & $Selected & ".nota") + EndIf + DBRefresh() + + Case $ToTXT + $Selected = GUICtrlRead($NoteDB) + $SrcData = GUICtrlRead($NoteContent) + $ExportTarget = _WinAPI_SaveFileDlg("Export as TXT",@MyDocumentsDir,"*.txt","",$Selected,".txt",$OFN_PATHMUSTEXIST) + $File = FileOpen($ExportTarget,2) + FileWrite($File,$SrcData) + + Case $ToMD + $Selected = GUICtrlRead($NoteDB) + $SrcData = GUICtrlRead($NoteContent) + $ExportTarget = _WinAPI_SaveFileDlg("Export as MD",@MyDocumentsDir,"*.md","",$Selected,".md",$OFN_PATHMUSTEXIST) + $File = FileOpen($ExportTarget,2) + FileWrite($File,$SrcData) + + Case $ToRTF + $Selected = GUICtrlRead($NoteDB) + $SrcData = GUICtrlRead($NoteContent) + $ExportTarget = _WinAPI_SaveFileDlg("Export as RTF",@MyDocumentsDir,"*.rtf","",$Selected,".rtf",$OFN_PATHMUSTEXIST) + $File = FileOpen($ExportTarget,2) + FileWrite($File,$SrcData) + + Case $Edit_PasteAppend + $Clipboard_Data = ClipGet() + $CurrentData = GUICtrlRead($NoteContent) + $FormattedData = $CurrentData & @CRLF & $Clipboard_Data + GUICtrlSetData($NoteContent,$FormattedData) + + Case $Rename + $Selected = GUICtrlRead($NoteDB) + $NewName = InputBox("New Name ?","Enter a new name",$Selected) + FileMove($baseloc & "\" & $Selected & ".nota",$baseloc & "\" & $NewName & ".nota") + DBRefresh() + + Case $ArchiveIt + $Selected = GUICtrlRead($NoteDB) + FileMove($baseloc & "\" & $Selected & ".nota",$baseloc & "\Archived\" & $Selected & ".nota") + DBRefresh() + + Case $Edit_PasteReplace + $Confirm = MsgBox(4,"Confirm Replace","This action replace all the note content case with your clipboard content." & @CRLF & "Confirm by selecting Yes/Oui") + if $Confirm = 6 Then + $Clipboard_Data = ClipGet() + GUICtrlSetData($NoteContent,$Clipboard_Data) + EndIf + + Case $Edit_CopyAll + $NoteCopy1 = GUICtrlRead($NoteTitle) + $NoteCopy2 = GUICtrlRead($NoteContent) + $NoteAuthor = @UserName + ClipPut($NoteCopy1 & @CRLF & "---------------------------------" & @CRLF & $NoteCopy2 & @CRLF & "---------------------------------" & @CRLF & "By " & $NoteAuthor & " using Leo Notes" & @CRLF) + Case $DBOpen + ShellExecute($baseloc) + + Case $Archive_Open + ShellExecute($baseloc & "\Archived") + + Case $Version_About + TyleoAbout("Leo Nota " & $CurrentVersion) + + Case $DBRefresh + DBRefresh() + + Case $Files_Import_TXT + $selectfile = _WinAPI_OpenFileDlg("Select TextFile(TXT) file to import as Note",@MyDocumentsDir,"*.txt","","","") + ; FileOpenDialog("Select TXT file to import as Note",@MyDocumentsDir,"*.txt",1+2+4,"",$GUI) + if @error Then + ; + Else + For $file In $selectfile + ; ConsoleWrite($files & @CRLF) + FileCopy($file,$baseloc) + Next + $db_files_a = _FileListToArray($baseloc,"*.txt",1,False) + for $dfile In $db_files_a + $dPool = FileOpen($dfile,0) + StringTrimRight($dfile,4) + FileWrite($baseloc & "\" & $dfile & $ext,$dPool) + Next + for $tFile In $db_files_a + FileDelete($baseloc & "\" & $tFile) + Next + EndIf + + Case $Files_Import_MD + $selectfile = _WinAPI_OpenFileDlg("Select MarkDown(MD) file to import as Note",@MyDocumentsDir,"*.md","","","") + + ; FileOpenDialog("Select MarkDown(MD) file to import as Note",@MyDocumentsDir,"*.txt",1+2+4,"",$GUI) + if @error Then + ; + Else + For $file In $selectfile + ; ConsoleWrite($files & @CRLF) + FileCopy($file,$baseloc) + Next + $db_files_a = _FileListToArray($baseloc,"*.md",1,False) + for $dfile In $db_files_a + $dPool = FileOpen($dfile,0) + StringTrimRight($dfile,4) + FileWrite($baseloc & "\" & $dfile & $ext,$dPool) + Next + for $tFile In $db_files_a + FileDelete($baseloc & "\" & $tFile) + Next + EndIf + + Case $Config_Font + _Metro_MsgBox(0,"Choose your font","Only Font Name, Font Size and Font Weight are saved. Color must be set using the another feature in menu.") + $selectfont = _ChooseFont($fontface,$fontsize,$fontcolor,$fontweight,"","","",$GUI) + ; Output Reference + ; "Font : $selectfont[2] + ; "Size : $selectfont[3] + ; "Weight : $selectfont[4] + ;--------------------------- + if @error Then + ; + Else + IniWrite($cfgfile,"configuration","fontface",$selectfont[2]) + IniWrite($cfgfile,"configuration","font size",$selectfont[3]) + IniWrite($cfgfile,"configuration","font weight",$selectfont[4]) + EndIf + + $fontface = IniRead($cfgfile,"configuration","fontface","Segoe UI") + $fontsize = IniRead($cfgfile,"configuration","font size","10") + $fontweight = IniRead($cfgfile,"configuration","font weight","400") + + GUICtrlSetFont($NoteContent,$fontsize,$fontweight,"",$fontface) + GUICtrlSetFont($NoteTitle,"9.5",$fontweight,"",$fontface) + GUICtrlSetFont($NoteDB,"9.5",$fontweight,"",$fontface) + + Case $Config_Bk + $selectcolor = _ChooseColor(2,$backcolor,2,$GUI) + + IniWrite($cfgfile,"configuration","background color",$selectcolor) + $backcolor = IniRead($cfgfile,"configuration","background color","0xFFFFFF") + + GUICtrlSetBkColor($NoteContent,$backcolor) + GUICtrlSetBkColor($NoteTitle,$backcolor) + GUICtrlSetBkColor($NoteDB,$backcolor) + + Case $Config_Bk_acc + + IniWrite($cfgfile,"configuration","background color",$CurrentAccent) + $backcolor = IniRead($cfgfile,"configuration","background color","0xFFFFFF") + + GUICtrlSetBkColor($NoteContent,$backcolor) + GUICtrlSetBkColor($NoteTitle,$backcolor) + GUICtrlSetBkColor($NoteDB,$backcolor) + + Case $Config_Fk + + $selectcolor = _ChooseColor(2,$fontcolor,2,$GUI) + + IniWrite($cfgfile,"configuration","font color",$selectcolor) + $fontcolor = IniRead($cfgfile,"configuration","font color","0xFFFFFF") + + GUICtrlSetColor($NoteContent,$fontcolor) + GUICtrlSetColor($NoteTitle,$fontcolor) + GUICtrlSetColor($NoteDB,$fontcolor) + + Case $Config_ChangeDatabaseLoc + $selectdb = _WinAPI_BrowseForFolderDlg("","Select new DB location (move everything)",$BIF_USENEWUI,"","",$GUI) + $sCheck = DirIsEmpty($selectdb) + + if $sCheck = 0 Then + MsgBox(0+16,"Error","The folder is not empty." & @CRLF & "Select or create a new folder for that.") + Else + if $selectdb = @MyDocumentsDir or $selectdb = @AppDataDir or $selectdb = @LocalAppDataDir or $selectdb = @UserProfileDir Then + MsgBox(0+16,"Error","The folder is a System/User PATH folder. It cannot be used for this purpose." & @CRLF & "Select or create a new folder for that.") + Else + If $sCheck = -1 Then + DirCreate($selectdb) + EndIf + $db = $selectdb + IniWrite($cfgfile,"configuration","database location",$db) + FileCopy($baseloc,$db,1) + Sleep(250) + FileDelete($baseloc & "\*") + MsgBox(0,"Success","Restarting Software...",3,$GUI) + Run(@AutoItExe) + Exit(0) + EndIf + EndIf + + Case $Archive_Export + $target = _WinAPI_BrowseForFolderDlg("","Choose export location, Data are zipped using the current date-time") + + DateGet() + $zipfile = $target & "\archive_" & @UserName & "_" & $CurrentTimeFormated & "_" & $CurrentDateFormated & ".zip" + + _Zip_Create($zipfile) + + $ArchivedNotes = _FileListToArray($baseloc & "\Archived","*.nota",1,False) + for $Note in $ArchivedNotes + _Zip_AddItem($zipfile,$baseloc & "\Archived\" & $Note,$target) + Next + + EndSwitch +WEnd + + +Func DirIsEmpty($Dir) + Local $Search, $i, $File + + If StringRight($Dir,1) <> "\" then $Dir = $Dir & "\" + $Search = FileFindFirstFile($Dir & "*.*") + + If $Search = -1 Then Return -1 + + While 1 + $File = FileFindNextFile($Search) + If @error Then ExitLoop + $i= $i + 1 + If $i > 2 then ExitLoop + WEnd + FileClose($Search) + If $i = 2 then Return 1 +EndFunc + +Func DBRefresh() + GUICtrlSetData($NoteDB,"") + Sleep(0.5) + $db_notes = _FileListToArray($baseloc,"*.nota",1) + _ArrayTrim($db_notes,5,1) + $sdb_notes = _ArrayToString($db_notes) + if $sdb_notes = "-1" Or $sdb_notes = -1 Then + $sdb_notes = "" + EndIf + GUICtrlSetData($NoteDB,$sdb_notes) +EndFunc + +Func DateGet() + Global $CurrentTimeFormated,$CurrentDateFormated + $CurrentTime = _NowTime(5) + $CurrentTimeFormated = StringReplace($CurrentTime,":","-") + $CurrentDate = _NowCalcDate() + $CurrentDateFormated = StringReplace($CurrentDate,"/","-") +EndFunc \ No newline at end of file diff --git a/Leo Notes/Leo Notes.exe b/Leo Notes/Leo Notes.exe new file mode 100755 index 0000000..6832c33 Binary files /dev/null and b/Leo Notes/Leo Notes.exe differ diff --git a/Leo Notes/Leo.ico b/Leo Notes/Leo.ico new file mode 100755 index 0000000..9df43dc Binary files /dev/null and b/Leo Notes/Leo.ico differ diff --git a/Leo Notes/Leo.png b/Leo Notes/Leo.png new file mode 100755 index 0000000..db418ea Binary files /dev/null and b/Leo Notes/Leo.png differ diff --git a/Leo Notes/MetroGUI-UDF/MetroGUI_UDF.au3 b/Leo Notes/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/Leo Notes/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/Leo Notes/MetroGUI-UDF/MetroThemes.au3 b/Leo Notes/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/Leo Notes/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/Leo Notes/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/Leo Notes/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/Leo Notes/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/Leo Notes/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/Leo Notes/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/Leo Notes/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/Leo Notes/MetroGUI-UDF/_GUIDisable.au3 b/Leo Notes/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/Leo Notes/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/Leo Notes/Outlook.au3 b/Leo Notes/Outlook.au3 new file mode 100755 index 0000000..60ef71c --- /dev/null +++ b/Leo Notes/Outlook.au3 @@ -0,0 +1,2826 @@ +#include-once +#Include +#Include +; #INDEX# ======================================================================================================================= +; Title .........: Outlook +; AutoIt Version: 3.3.0 +; Language: English +; Description ...: Functions that assist with MS Outlook +; =============================================================================================================================== + +; #CURRENT# ===================================================================================================================== +;_OutlookOpen +;_OutlookSendMail +;_OutlookGetMail +;_OutlookSaveMail +;_OutlookDeleteMail +;_OutlookCopyMail - Not started +;_OutlookMoveMail - Not started +;_OutlookCreateNote +;_OutlookGetNotes +;_OutlookDeleteNote +;_OutlookModifyNote +;_OutlookCreateTask +;_OutlookGetTasks +;_OutlookDeleteTask +;_OutlookModifyTask +;_OutlookCreateAppointment +;_OutlookGetAppointments +;_OutlookModifyAppointment - Modify single appointment in a recurring appointment doesn't work. +;_OutlookDeleteAppointment - Not started +;_OutlookCreateContact +;_OutlookGetContacts +;_OutlookModifyContact - Not started +;_OutlookDeleteContact - Not started +;_OutlookCreateDistList +;_OutlookGetDistLists +;_OutlookDeleteDistList +;_OutlookDeleteDistListMember +;_OutlookModifyDistList - Not working +;_OutlookFolderExist +;_OutlookFolderAdd +;_OutlookFolderDelete +;_OutlookError +; =============================================================================================================================== + +const $olForward=2 +const $olReply=0 +const $olReplyAll=1 +const $olReplyFolder=3 +const $olRespond=4 +const $olEmbedOriginalItem=1 +const $olIncludeOriginalText=2 +const $olIndentOriginalText=3 +const $olLinkOriginalItem=4 +const $olOmitOriginalText=0 +const $olReplyTickOriginalText=1000 +const $olUserPreference=5 +const $olOpen=0 +const $olPrompt=2 +const $olSend=1 +const $olDontShow=0 +const $olMenu=1 +const $olMenuAndToolbar=2 +const $olByReference=4 +const $olByValue=1 +const $olEmbeddeditem=5 +const $olOLE=6 +const $olFormatHTML=2 +const $olFormatPlain=1 +const $olFormatRichText=3 +const $olFormatUnspecified=0 +const $olBusy=2 +const $olFree=0 +const $olOutOfOffice=3 +const $olTentative=1 +const $olLowBandwidth=200 +const $olFriday=32 +const $olMonday=2 +const $olSaturday=64 +const $olSunday=1 +const $olThursday=16 +const $olTuesday=4 +const $olWednesday=8 +const $olFolderCalendar=9 +const $olFolderContacts=10 +const $olFolderDeletedItems=3 +const $olFolderDrafts=16 +const $olFolderInbox=6 +const $olFolderJournal=11 +const $olFolderJunk=23 +const $olFolderNotes=12 +const $olFolderOutbox=4 +const $olFolderSentMail=5 +const $olFolderTasks=13 +const $olPublicFoldersAllPublicFolders=18 +const $olFolderConflicts=19 +const $olFolderLocalFailures=21 +const $olFolderServerFailures=22 +const $olFolderSyncIssues=20 +const $olAgent=3 +const $olDistList=1 +const $olForum=2 +const $olOrganization=4 +const $olPrivateDistList=5 +const $olRemoteUser=6 +const $olUser=0 +const $olFullItem=1 +const $olHeaderOnly=0 +const $olEditorHTML=2 +const $olEditorRTF=3 +const $olEditorText=1 +const $olEditorWord=4 +const $olCachedConnectedDrizzle=600 +const $olCachedConnectedFull=700 +const $olCachedConnectedHeaders=500 +const $olCachedDisconnected=400 +const $olCachedOffline=200 +const $olDisconnected=300 +const $olNoExchange=0 +const $olOffline=100 +const $olOnline=800 +const $olBlueFlagIcon=5 +const $olGreenFlagIcon=3 +const $olNoFlagIcon=0 +const $olOrangeFlagIcon=2 +const $olPurpleFlagIcon=1 +const $olRedFlagIcon=6 +const $olYellowFlagIcon=4 +const $olFlagComplete=1 +const $olFlagMarked=2 +const $olNoFlag=0 +const $olFolderDisplayFolderOnly=1 +const $olFolderDisplayNoNavigation=2 +const $olFolderDisplayNormal=0 +const $olDefaultRegistry=0 +const $olFolderRegistry=3 +const $olOrganizationRegistry=4 +const $olPersonalRegistry=2 +const $olFemale=1 +const $olMale=2 +const $olUnspecified=0 +const $olImportanceHigh=2 +const $olImportanceLow=0 +const $olImportanceNormal=1 +const $olDiscard=1 +const $olPromptForSave=2 +const $olSave=0 +const $olAppointmentItem=1 +const $olContactItem=2 +const $olDistributionListItem=7 +const $olJournalItem=4 +const $olMailItem=0 +const $olNoteItem=5 +const $olPostItem=6 +const $olTaskItem=3 +const $olAssociatedContact=1 +const $olBusiness=2 +const $olHome=1 +const $olNone=0 +const $olOther=3 +const $olBCC=3 +const $olCC=2 +const $olOriginator=0 +const $olTo=1 +const $olOptional=2 +const $olOrganizer=0 +const $olRequired=1 +const $olResource=3 +const $olMeetingAccepted=3 +const $olMeetingDeclined=4 +const $olMeetingTentative=2 +const $olMeeting=1 +const $olMeetingCanceled=5 +const $olMeetingReceived=3 +const $olNonMeeting=0 +const $olExchangeConferencing=2 +const $olNetMeeting=0 +const $olNetShow=1 +const $olBlue=0 +const $olGreen=1 +const $olPink=2 +const $olWhite=4 +const $olYellow=3 +const $olAction=32 +const $olActions=33 +const $olAddressEntries=21 +const $olAddressEntry=8 +const $olAddressList=7 +const $olAddressLists=20 +const $olApplication=0 +const $olAppointment=26 +const $olAttachment=5 +const $olAttachments=18 +const $olConflict=117 +const $olConflicts=118 +const $olContact=40 +const $olDistributionList=69 +const $olDocument=41 +const $olException=30 +const $olExceptions=29 +const $olExplorer=34 +const $olExplorers=60 +const $olFolder=2 +const $olFolders=15 +const $olFormDescription=37 +const $olInspector=35 +const $olInspectors=61 +const $olItemProperties=98 +const $olItemProperty=99 +const $olItems=16 +const $olJournal=42 +const $olLink=75 +const $olLinks=76 +const $olMail=43 +const $olMeetingCancellation=54 +const $olMeetingRequest=53 +const $olMeetingResponseNegative=55 +const $olMeetingResponsePositive=56 +const $olMeetingResponseTentative=57 +const $olNamespace=1 +const $olNote=44 +const $olOutlookBarGroup=66 +const $olOutlookBarGroups=65 +const $olOutlookBarPane=63 +const $olOutlookBarShortcut=68 +const $olOutlookBarShortcuts=67 +const $olOutlookBarStorage=64 +const $olPages=36 +const $olPanes=62 +const $olPost=45 +const $olPropertyPages=71 +const $olPropertyPageSite=70 +const $olRecipient=4 +const $olRecipients=17 +const $olRecurrencePattern=28 +const $olReminder=101 +const $olReminders=100 +const $olRemote=47 +const $olReport=46 +const $olResults=78 +const $olSearch=77 +const $olSelection=74 +const $olSyncObject=72 +const $olSyncObjects=73 +const $olTask=48 +const $olTaskRequest=49 +const $olTaskRequestAccept=51 +const $olTaskRequestDecline=52 +const $olTaskRequestUpdate=50 +const $olUserProperties=38 +const $olUserProperty=39 +const $olView=80 +const $olViews=79 +const $olExcelWorkSheetItem=8 +const $olPowerPointShowItem=10 +const $olWordDocumentItem=9 +const $olLargeIcon=0 +const $olSmallIcon=1 +const $olFolderList=2 +const $olNavigationPane=4 +const $olOutlookBar=1 +const $olPreview=3 +const $olDoNotForward=1 +const $olPermissionTemplate=2 +const $olUnrestricted=0 +const $olUnknown=0 +const $olWindows=1 +const $olPassport=2 +const $olApptException=3 +const $olApptMaster=1 +const $olApptNotRecurring=0 +const $olApptOccurrence=2 +const $olRecursDaily=0 +const $olRecursMonthly=2 +const $olRecursMonthNth=3 +const $olRecursWeekly=1 +const $olRecursYearly=5 +const $olRecursYearNth=6 +const $olMarkedForCopy=3 +const $olMarkedForDelete=4 +const $olMarkedForDownload=2 +const $olRemoteStatusNone=0 +const $olUnMarked=1 +const $olResponseAccepted=3 +const $olResponseDeclined=4 +const $olResponseNone=0 +const $olResponseNotResponded=5 +const $olResponseOrganized=1 +const $olResponseTentative=2 +const $olDoc=4 +const $olHTML=5 +const $olICal=8 +const $olMSG=3 +const $olMSGUnicode=9 +const $olRTF=1 +const $olTemplate=2 +const $olTXT=0 +const $olVCal=7 +const $olVCard=6 +const $olConfidential=3 +const $olNormal=0 +const $olPersonal=1 +const $olPrivate=2 +const $olNoItemCount=0 +const $olShowTotalItemCount=2 +const $olShowUnreadItemCount=1 +const $olAscending=1 +const $olDescending=2 +const $olSortNone=0 +const $olStoreANSI=3 +const $olStoreDefault=1 +const $olStoreUnicode=2 +const $olSyncStarted=1 +const $olSyncStopped=0 +const $olTaskDelegationAccepted=2 +const $olTaskDelegationDeclined=3 +const $olTaskDelegationUnknown=1 +const $olTaskNotDelegated=0 +const $olDelegatedTask=1 +const $olNewTask=0 +const $olOwnTask=2 +const $olFinalStatus=3 +const $olUpdate=2 +const $olTaskAccept=2 +const $olTaskAssign=1 +const $olTaskDecline=3 +const $olTaskSimple=0 +const $olTaskComplete=2 +const $olTaskDeferred=4 +const $olTaskInProgress=1 +const $olTaskNotStarted=0 +const $olTaskWaiting=3 +const $olTrackingDelivered=1 +const $olTrackingNone=0 +const $olTrackingNotDelivered=2 +const $olTrackingNotRead=3 +const $olTrackingRead=6 +const $olTrackingRecallFailure=4 +const $olTrackingRecallSuccess=5 +const $olTrackingReplied=7 +const $olCombination=19 +const $olCurrency=14 +const $olDateTime=5 +const $olDuration=7 +const $olFormula=18 +const $olKeywords=11 +const $olNumber=3 +const $olOutlookInternal=0 +const $olPercent=12 +const $olText=1 +const $olYesNo=6 +const $olViewSaveOptionAllFoldersOfType=2 +const $olViewSaveOptionThisFolderEveryone=0 +const $olViewSaveOptionThisFolderOnlyMe=1 +const $olCalendarView=2 +const $olCardView=1 +const $olIconView=3 +const $olTableView=0 +const $olTimelineView=4 + +;=============================================================================== +; +; Function Name: _OutlookOpen() +; Description: Open a connection to Microsoft Outlook. +; Syntax.........: _OutlookOpen() +; Parameter(s): None +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Returns new object identifier +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Unable to Create Outlook Object. +; Author(s): Wooltown +; Created: 2009-02-09 +; Modified: - +; +;=============================================================================== +Func _OutlookOpen() + Local $oOutlook = ObjCreate("Outlook.Application") + If @error Or Not IsObj($oOutlook) Then + Return SetError(1, 0, 0) + EndIf + Return $oOutlook +EndFunc +;=============================================================================== +; +; Function Name: _OutlookSendMail() +; Description: Send an email using Microsoft Outlook. +; Syntax.........: _OutlookSendMail($oOutlook, $sTo = "", $sCc = "", $sBCc = "", $sSubject = "", $sBody = "", $sAttachments = "", $iBodyFormat = $olFormatUnspecified, $iImportance = $olImportanceNormal, $sWarningClick = "") +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen() +; $sTo - Optional: The recipiant(s), separated by ; +; $sCc - Optional: The CC recipiant(s) of the mail, separated by ; +; $sBCc - Optional: The BCC recipiant(s) of the mail, separated by ; +; $sSubject - Optional: The Subject of the mail +; $sBody - Optional: The Body of the mail +; $sAttachments - Optional: Attachments, separated by ; +; $iBodyFormat - Optional: The Bodyformat of the mail, default = $olFormatUnspecified +; $iImportance - Optional: The Importance of the mail, default = $olImportanceNormal +; $sWarningClick - Optional: The Entire SearchString to 'OutlookWarning1.exe', Default = None +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - No To, Cc or BCc specified. +; @ERROR = 2 - OutlookWarning1.exe not found. +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-02-09 +; Modified: 2009-02-24 - Several attachments didn't work +; +;=============================================================================== +Func _OutlookSendMail($oOutlook, $sTo = "", $sCc = "", $sBcc = "", $sSubject = "", $sBody = "", $sAttachments = "", $iBodyFormat = $olFormatPlain, $iImportance = $olImportanceNormal, $sWarningClick = "") + Local $iRc = 0, $asAttachments + If $sTo = "" And $sCc = "" And $sBCc = "" Then + Return SetError(1, 0, 0) + EndIf + If $sWarningClick <> "" And FileExists($sWarningClick) = 0 Then + Return SetError(2, 0, 0) + Else + Run($sWarningClick) + EndIf + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Local $oMessage = $oOutlook.CreateItem($olMailItem) + $oMessage.To = $sTo + $oMessage.Cc = $sCc + $oMessage.Bcc = $sBCc + $oMessage.Subject = $sSubject + $oMessage.Body = $sBody + $oMessage.BodyFormat = $iBodyFormat + $oMessage.Importance = $iImportance + If $sAttachments <> "" Then + $asAttachments = StringSplit($sAttachments,";") + For $iNumOfAttachments = 1 to $asAttachments[0] + $oMessage.Attachments.Add($asAttachments[$iNumOfAttachments]) + Next + EndIf + $oMessage.Send + $iRc = @ERROR + If $iRc = 0 Then + Return 1 + Else + Return SetError(9, 0, 0) + EndIf +EndFunc +;=============================================================================== +; +; Function Name: _OutlookGetMail() +; Description: Get all email using Microsoft Outlook. +; Syntax.........: _OutlookGetMail($oOutlook, $sFolder = $olFolderInbox, $fSubFolder = False, $sFrom = "", $sTo = "", $sCc = "", $sBCc = "", $sSubject = "", $iImportance = "", $fOnlyReturnUnread = False, $sWarningClick = "", $iSetStatus = 0, $fCountMailOnly = False) +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen() +; $sFolder - Optional: Folder, default = $olFolderInbox, add subfolders if wish to start search at a lower level, ex: $olFolderInbox & "\Archive" +; If you wish to access the root, use "\", Sent Items, write "\Sent Items" +; $fSubFolders - Optional: Search subfolders, default = False +; $sFrom - Optional: The e-mail address of the sender +; $sTo - Optional: The recipiant(s) +; $sCc - Optional: The CC recipiant(s) of the mail +; $sBCc - Optional: The BCC recipiant(s) of the mail +; $sSubject - Optional: The Subject of the mail +; $iImportance - Optional: The Importance of the mail +; $fOnlyReturnUnread - Optional: Default = False, set to True if you only wish the unread. +; $sWarningClick - Optional: The Entire SearchString to 'OutlookWarning2.exe', Default = None +; $iSetStatus - Optional: - 0 - Don't change status +; 1 - Set as Read +; 2 - Set as UnRead +; 3 - Change status Read > Unread, Unread > Read +; $fCountMailOnly - False - Report all +; True - Report only number of items +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Array in the following format: [10000][16] +; [0][0] - Total Number of items +; [0][1] - Number of unread items +; [1][0] - Sender name +; [1][1] - Sender Email address +; [1][2] - To +; [1][3] - Cc +; [1][4] - Bcc +; [1][5] - ReceivedTime +; [1][6] - SentOn +; [1][7] - Subject +; [1][8] - Folder +; [1][9] - Body +; [1][10] - BodyFormat +; [1][11] - Importance +; [1][12] - Unread +; [1][13] - Size +; [1][14] - FlagIcon +; [1][15] - Attachments +; [1][16] - Class - $olMail, $olMeetingRequest Or $olTaskRequest +; [n][n] - Item n +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Illegal parameters +; @ERROR = 2 - OutlookWarning2.exe not found. +; @ERROR = 3 - No Mail found/Folder not found. +; @ERROR = 4 - More than 9999 Mail, the first 9999 mail will be returned +; @ERROR = 5 - Mailfolder not found +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-02-25 +; Modified: 2009-03-02 +; 2009-03-10 - If folder not found, an error occured +; 2009-06-08 - Added $fCountMailOnly +; +;=============================================================================== +Func _OutlookGetMail($oOutlook, $sFolder = $olFolderInbox, $fSubFolders = False, $sFrom = "", $sTo = "", $sCc = "", $sBCc = "", $sSubject = "", $iImportance = "", $fOnlyReturnUnread = False, $sWarningClick = "", $iSetStatus = 0, $fCountMailOnly = False) + If $sWarningClick <> "" And FileExists($sWarningClick) = 0 Then + Return SetError(2, 0, 0) + Else + Run($sWarningClick) + EndIf + Local $fRoot = False, $oFolder, $fOtherMailBox = False + If StringLeft($sFolder,2) = "\\" Then + $fOtherMailBox = True + Local $asFolderID = StringSplit(StringMid($sFolder,3),"\\",1) + _Arraydisplay($asFolderID) + Else + If StringLeft($sFolder,1) = "\" Then + $fRoot = True + $sFolder = StringMid($sFolder,2) + EndIf + EndIf + If $iImportance < 0 Or $iImportance > 2 Then Return SetError(1, 0, 0) + If $fCountMailOnly = True Then + Local $asMail[1][2] + Else + Local $asMail[10000][17] + EndIf + Local $iRc = 0, $iFolderFound = 1 + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Local $oNamespace = $oOutlook.GetNamespace("MAPI") + If StringRight($sFolder,1) = "\" Then $sFolder = StringLeft($sFolder,StringLen($sFolder) - 1) + Local $sSubFolderParts = StringSplit ( $sFolder, "\"), $sFolderName + If $fOtherMailBox = True Then + Local $oSession = $oOutlook.Session + $oFolder = $oSession.GetFolderFromID($asFolderID[1], $asFolderID[2]) + msgbox(0,"obj",isobj($oFolder)) + EndIf + If $fRoot = True Then + $sSubFolderParts[0] = 0 + Local $oInbox = $oNamespace.GetDefaultFolder($olFolderInbox) + If $sFolder = "" Then + $oFolder = $oInbox.Parent + Else + $sFolderName = $oInbox.Parent + ;$sFolderName = $sFolderName.Parent + For $idx = 1 To $sFolderName.Folders.Count + If $sFolderName.Folders.Item($idx).Name = $sFolder Then $oFolder = $sFolderName.Folders.Item($idx) + Next + EndIf + Else + If $fOtherMailBox = False Then $oFolder = $oNamespace.GetDefaultFolder($sSubFolderParts[1]) + EndIf + If IsObj($oFolder) = 0 Then Return SetError(5, 0, 0) + Local $sRootFolderName = $oFolder.Name + msgbox(0,"folder",$sRootFolderName) + $asMail[0][0] = 0 + $asMail[0][1] = 0 + If $fOtherMailBox = False And $sSubFolderParts[0] > 1 Then + $iFolderFound = _OutlookFindRootFolder($oFolder,$sRootFolderName,StringMid($sFolder,StringInStr($sFolder,"\")+ 1)) + EndIf + If $iFolderFound = 0 Then Return SetError(5, 0, 0) + _OutlookFindMailInTree($asMail, $oFolder, $sRootFolderName, $fSubFolders, $sFrom, $sTo, $sCc, $sBCc, $sSubject, $iImportance, $fOnlyReturnUnread, $iSetStatus, $fCountMailOnly) + $iRc = @ERROR + If $iRc = 4 Then SetError (4) + If $asMail[0][0] = 0 Then Return SetError(3, 0, 0) + If $fCountMailOnly = False Then + If $fOnlyReturnUnread = True Then + Redim $asMail[$asMail[0][1] + 1][17] + Else + Redim $asMail[$asMail[0][0] + 1][17] + EndIf + _ArraySort($asMail,1,1,0,5) + EndIf + Return $asMail +EndFunc +;=============================================================================== +; +; Function Name: _OutlookSaveMail() +; Description: Save an email from Microsoft Outlook, you must specify enough parameters so you will have a unique mail. +; Syntax.........: _OutlookSaveMail($oOutlook, $sFolder = $olFolderInbox, $sFrom = "", $sSubject = "", $sReceivedTime = "", $sSaveFormat = $olMSG, $sSaveDir = "", $sWarningClick = "", $iSetStatus = 0) +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen() +; $sFolder - Optional: Folder, default = $olFolderInbox, add subfolders if wish to start search at a lower level, ex: $olFolderInbox & "\Archive" +; $sFrom - Optional: The e-mail address of the sender +; $sSubject - Optional: The Subject of the mail +; $sReceivedTime - Optional: The Time the mail is received +; $sSaveFormat - Optional: Format to save the mail in, default = $olMSG, other values: $olTXT, $olHTML +; $sSaveDir - Optional: Directory to save the message and attachments, if not specified: attached files will not be saved. +; $sWarningClick - Optional: The Entire SearchString to 'OutlookWarning2.exe', Default = None +; $iSetStatus - Optional: - 0 - Don't change status +; 1 - Set as Read +; 2 - Set as UnRead +; 3 - Change status Read > Unread, Unread > Read +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Array containing +; [0] - Number of saved files, message and attachments +; [1] - Directory and Filename of the saved mail. +; [2] - Directory and Filename of the first saved file. +; [n] - Directory and Filename of the [n] saved file. +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Illegal parameters +; @ERROR = 2 - OutlookWarning2.exe not found. +; @ERROR = 3 - Mail not found/Folder not found. +; @ERROR = 4 - Directory specified doesn't exist +; @ERROR = 5 - More than one mail found +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-02-27 +; Modified: - +; +;=============================================================================== +Func _OutlookSaveMail($oOutlook, $sFolder = $olFolderInbox, $sFrom = "", $sSubject = "", $sReceivedTime = "", $sSaveFormat = $olMSG, $sSaveDir = "", $sWarningClick = "", $iSetStatus = 0) + If $sWarningClick <> "" And FileExists($sWarningClick) = 0 Then + Return SetError(2, 0, 0) + Else + Run($sWarningClick) + EndIf + Local $fRoot = False, $oFolder + If StringLeft($sFolder,1) = "\" Then + $fRoot = True + $sFolder = StringMid($sFolder,2) + EndIf + Local $sRootFolderName, $iRc = 0, $iAttachCnt, $oFilteredItems, $sFilter = "", $sFileName, $oTemp, $asResult[999], $sSuffix + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Local $oNamespace = $oOutlook.GetNamespace("MAPI") + Local $sSubFolderParts = StringSplit ( $sFolder, "\") + $oFolder = $oNamespace.GetDefaultFolder($sSubFolderParts[1]) + If $fRoot = True Then + $sSubFolderParts[0] = 0 + Local $oInbox = $oNamespace.GetDefaultFolder($olFolderInbox) + If $sFolder = "" Then + $oFolder = $oInbox.Parent + Else + Local $sFolderName = $oInbox.Parent + For $idx = 1 To $sFolderName.Folders.Count + If $sFolderName.Folders.Item($idx).Name = $sFolder Then $oFolder = $sFolderName.Folders.Item($idx) + Next + EndIf + Else + $oFolder = $oNamespace.GetDefaultFolder($sSubFolderParts[1]) + EndIf + If $sFrom = "" And $sSubject = "" And $sReceivedTime = "" Then Return SetError(1, 0, 0) + If Not ($sSaveFormat = $olMSG Or $sSaveFormat = $olTXT Or $sSaveFormat = $olHTML) Then Return SetError(1, 0, 0) + Switch $sSaveFormat + Case $olMSG + $sSuffix = ".msg" + Case $olTXT + $sSuffix = ".txt" + Case $olHTML + $sSuffix = ".html" + EndSwitch + If FileExists($sSaveDir) = 0 Or StringInStr(FileGetAttrib ($sSaveDir),"D") = 0 Then Return SetError(4, 0, 0) + If StringRight($sSaveDir,1) <> "\" Then $sSaveDir &= "\" + $sRootFolderName = $oFolder.Name + $asResult[0] = 0 + If $sSubFolderParts[0] > 1 Then + _OutlookFindRootFolder($oFolder,$sRootFolderName,StringMid($sFolder,StringInStr($sFolder,"\")+ 1)) + EndIf + Local $oMailItems = $oFolder.Items + If $sFrom <> "" Then + $sFilter = '[SenderName] = "' & $sFrom & '"' + EndIf + If $sSubject <> "" Then + If $sFilter <> "" Then $sFilter &= ' And ' + $sFilter &= '[Subject] = "' & $sSubject & '"' + EndIf + If $sReceivedTime <> "" Then + If Not _DateIsValid($sReceivedTime) Then Return SetError(1, 0, 0) + If $sFilter <> "" Then $sFilter &= ' And ' + $sFilter &= '[ReceivedTime] = "' & $sReceivedTime & '"' + EndIf + $oFilteredItems = $oMailItems.Restrict($sFilter) + If $oFilteredItems.Count = 0 Then Return SetError(3, 0, 0) + If $oFilteredItems.Count > 1 Then Return SetError(5, 0, 0) + For $oItem In $oFilteredItems + $sSubject = StringRegExpReplace($oItem.Subject,'[\/:*?"<>|]', '_') + $oItem.SaveAs ($sSaveDir & $sSubject & $sSuffix, $sSaveFormat ) + $asResult[0] += 1 + $asResult[$asResult[0]] = $sSaveDir & $sSubject & $sSuffix + If $sSaveDir <> "" Then + $iAttachCnt = $oItem.Attachments.Count + If $iAttachCnt > 0 Then + For $iAttachNum = 1 to $iAttachCnt + $oTemp = $oItem.Attachments.Item($iAttachNum) + $sFileName = $iAttachNum & "_" & $oTemp.FileName + $oTemp = $oItem.Attachments.Item($iAttachNum) + $asResult[0] += 1 + $asResult[$asResult[0]] = $sSaveDir & $sFileName + $oTemp.SaveAsFile ($sSaveDir & $sFileName ) + Next + EndIf + EndIf + Switch $iSetStatus + Case 1 + $oItem.UnRead = False + Case 2 + $oItem.UnRead = True + Case 3 + If $oItem.UnRead = False Then + $oItem.UnRead = True + Else + $oItem.UnRead = False + EndIf + EndSwitch + Next + $iRc = @ERROR + If $iRc = 0 Then + Redim $asResult[$asResult[0] + 1] + Return $asResult + Else + Return SetError(9, 0, 0) + EndIf +EndFunc +;=============================================================================== +; +; Function Name: _OutlookDeleteMail() +; Description: Delete one or more email from Microsoft Outlook, you must specify enough parameters so you will have a unique mail or set $fDeleteMultipleMail = True +; Syntax.........: _OutlookDeleteMail($oOutlook, $sFolder = $olFolderInbox, $sFrom = "", $sSubject = "", $sReceivedTime = "", $fDeleteMultipleMail = False, $fRemoveFromDeletedItems = False, $sWarningClick = "") +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen() +; $sFolder - Optional: Folder, default = $olFolderInbox, add subfolders if wish to start search at a lower level, ex: $olFolderInbox & "\Archive" +; $sFrom - Optional: The e-mail address of the sender +; $sSubject - Optional: The Subject of the mail +; $sReceivedTime - Optional: The Time the mail is received +; $fDeleteMultipleMail - Optional: Default: False, True - If you wish to delete multiple files +; $fRemoveFromDeletedItems- Optional: Default: False, True - If you wish to delete the files from Deleted Items as well +; $sWarningClick - Optional: The Entire SearchString to 'OutlookWarning2.exe', Default = None +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Array containing +; [0] - Number of deleted mails +; [1] - Deleted Mail 1 +; [2] - Deleted Mail 2 +; [n] - Deleted Mail n +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Illegal parameters +; @ERROR = 2 - OutlookWarning2.exe not found. +; @ERROR = 3 - Mail not found/Folder not found. +; @ERROR = 4 - More than one mail found, and $fDeleteMultipleMail = False +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-02-27 +; Modified: - +; +;=============================================================================== +Func _OutlookDeleteMail($oOutlook, $sFolder = $olFolderInbox, $sFrom = "", $sSubject = "", $sReceivedTime = "", $fDeleteMultipleMail = False, $fRemoveFromDeletedItems = False, $sWarningClick = "") + If $sWarningClick <> "" And FileExists($sWarningClick) = 0 Then + Return SetError(2, 0, 0) + Else + Run($sWarningClick) + EndIf + Local $sRootFolderName, $iRc = 0, $oFilteredItems, $sFilter = "", $asResult[999], $aoDelete[999], $oDelete + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Local $oNamespace = $oOutlook.GetNamespace("MAPI") + Local $sSubFolderParts = StringSplit ( $sFolder, "\") + Local $oFolder = $oNamespace.GetDefaultFolder($sSubFolderParts[1]) + If $sFrom = "" And $sSubject = "" And $sReceivedTime = "" Then Return SetError(1, 0, 0) + $sRootFolderName = $oFolder.Name + $asResult[0] = 0 + If $sSubFolderParts[0] > 1 Then + _OutlookFindRootFolder($oFolder,$sRootFolderName,StringMid($sFolder,StringInStr($sFolder,"\")+ 1)) + EndIf + Local $oMailItems = $oFolder.Items + If $sFrom <> "" Then + $sFilter = '[SenderName] = "' & $sFrom & '"' + EndIf + If $sSubject <> "" Then + If $sFilter <> "" Then $sFilter &= ' And ' + $sFilter &= '[Subject] = "' & $sSubject & '"' + EndIf + If $sReceivedTime <> "" Then + If Not _DateIsValid($sReceivedTime) Then Return SetError(1, 0, 0) + If $sFilter <> "" Then $sFilter &= ' And ' + $sFilter &= '[ReceivedTime] = "' & $sReceivedTime & '"' + EndIf + $oFilteredItems = $oMailItems.Restrict($sFilter) + If $oFilteredItems.Count = 0 Then Return SetError(3, 0, 0) + If $oFilteredItems.Count > 1 And $fDeleteMultipleMail = False Then Return SetError(4, 0, 0) + For $oItem In $oFilteredItems + $asResult[0] += 1 + $asResult[$asResult[0]] = $oItem.Subject & " - " & $oItem.SenderName & " - " & $oItem.ReceivedTime + $aoDelete[$asResult[0]] = $oItem + Next + For $iDeleteNr = 1 To $asResult[0] + $oDelete = $aoDelete[$iDeleteNr] + $oDelete.Delete + Next + If $fRemoveFromDeletedItems = True Then _OutlookDeleteMail($oOutlook, $olFolderDeletedItems, $sFrom, $sSubject, $sReceivedTime, True, False, $sWarningClick) + $iRc = @ERROR + If $iRc = 0 or $iRc = 1 Then + Redim $asResult[$asResult[0] + 1] + Return $asResult + Else + Return SetError(9, 0, 0) + EndIf +EndFunc +;=============================================================================== +; +; Function Name: _OutlookCreateNote() +; Description: Create a note using Microsoft Outlook. +; Syntax.........: _OutlookCreateNote($oOutlook, $sSubject, $sBody = "", $sCategories = "", $iColor = "") +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen() +; $sSubject - The Subject of the Note +; $sBody - Optional: The Body of the Note +; $sCategories - Optional: Categories for the note, separated by ; +; $iColor - Optional: The color of the Note, 0 - Blue, 1 - Green, 2 - Pink, 3 - Yellow, 4 - White +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-02-09 +; Modified: - +; +;=============================================================================== +Func _OutlookCreateNote($oOutlook, $sSubject, $sBody = "", $sCategories = "", $iColor = "") + Local $iRc = 0 + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Local $oNote = $oOutlook.CreateItem($olNoteItem) + $oNote.Categories = $sCategories + $oNote.Body = $sSubject & @CRLF & $sBody + $oNote.Color = $iColor + $oNote.Close ($olSave) + $iRc = @ERROR + If $iRc = 0 Then + Return 1 + Else + Return SetError(9, 0, 0) + EndIf +EndFunc +;=============================================================================== +; +; Function Name: _OutlookGetNotes() +; Description: Get the Notes in Microsoft Outlook +; Syntax.........: _OutlookGetNotes($oOutlook) +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen(). +; $sWarningClick - Optional: The Entire SearchString to 'OutlookWarning2.exe', Default = None +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Array in the following format: [1000][6] +; [0][0] - Number of items +; [1][0] - Subject +; [1][1] - Body +; [1][2] - Color +; [1][3] - Categories +; [1][4] - Creation time +; [1][5] - Last modification time +; [n][n] - Item n +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Illegal parameters +; @ERROR = 2 - OutlookWarning2.exe not found. +; @ERROR = 3 - More than 999 Notes found, the first 999 notes will be returned. +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-03-02 +; Modified: - +; +;=============================================================================== +Func _OutlookGetNotes($oOutlook,$sWarningClick = "") + If $sWarningClick <> "" And FileExists($sWarningClick) = 0 Then + Return SetError(2, 0, 0) + Else + Run($sWarningClick) + EndIf + Local $avNotes[1000][6] + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + $avNotes[0][0] = 0 + Local $oNamespace = $oOutlook.GetNamespace("MAPI") + Local $oFolder = $oNamespace.GetDefaultFolder($olFolderNotes) + Local $oColItems = $oFolder.Items + $oColItems.Sort("[Subject]") + For $oItem In $oColItems + If $avNotes[0][0] = 999 Then + SetError (3) + Return $avNotes + EndIf + $avNotes[0][0] += 1 + $avNotes[$avNotes[0][0]][0] = $oItem.Subject + $avNotes[$avNotes[0][0]][1] = $oItem.Body + $avNotes[$avNotes[0][0]][2] = $oItem.Color + $avNotes[$avNotes[0][0]][3] = $oItem.Categories + $avNotes[$avNotes[0][0]][4] = $oItem.CreationTime + $avNotes[$avNotes[0][0]][5] = $oItem.LastModificationTime + Next + $oItem = "" + $oColItems = "" + $oFolder = "" + $oNamespace = "" + If $avNotes[0][0] = 0 Then Return SetError(2, 0, 0) + Redim $avNotes[$avNotes[0][0] + 1][6] + Return $avNotes +EndFunc +;=============================================================================== +; +; Function Name: _OutlookDeleteNote() +; Description: Get the Notes in Microsoft Outlook +; Syntax.........: _OutlookDeleteNote($oOutlook, $sSubject, $fDeleteMultipleNotes = False, $sWarningClick = "") +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen(). +; $sSubject - The Subject of the Note +; $fDeleteMultipleNotes - Default : False - If True, delete multiple files with same subject. +; $sWarningClick - Optional: The Entire SearchString to 'OutlookWarning2.exe', Default = None +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Array in the following format: [999] +; [0] - Number of deleted notes +; [1] - Deleted note 1 +; [2] - Deleted note 2 +; [n] - Deleted note n +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Illegal parameters +; @ERROR = 2 - OutlookWarning2.exe not found. +; @ERROR = 3 - More than 999 Notes found matching criteria. +; @ERROR = 4 - 0 notes found +; @ERROR = 5 - More than 1 Notes found and $fDeleteMultipleFiles = False +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-03-02 +; Modified: - +; +;=============================================================================== +Func _OutlookDeleteNote($oOutlook, $sSubject, $fDeleteMultipleNotes = False, $sWarningClick = "") + If $sWarningClick <> "" And FileExists($sWarningClick) = 0 Then + Return SetError(2, 0, 0) + Else + Run($sWarningClick) + EndIf + Local $avNotes[1000], $oDelete, $aoDelete[1000] + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + $avNotes[0] = 0 + Local $oNamespace = $oOutlook.GetNamespace("MAPI") + Local $oFolder = $oNamespace.GetDefaultFolder($olFolderNotes) + Local $oColItems = $oFolder.Items + Local $oFilteredItems = $oColItems.Restrict('[Subject] = "' & $sSubject & '"') + $oColItems.Sort("[Subject]") + If $oFilteredItems.Count > 999 Then Return SetError(3, 0, 0) + If $oFilteredItems.Count = 0 Then Return SetError(4, 0, 0) + If $oFilteredItems.Count > 1 and $fDeleteMultipleNotes = False Then Return SetError(5, 0, 0) + For $oItem In $oFilteredItems + $avNotes[0] += 1 + $avNotes[$avNotes[0]] = $oItem.Body + $aoDelete[$avNotes[0]] = $oItem + Next + For $iDeleteNr = 1 To $avNotes[0] + $oDelete = $aoDelete[$iDeleteNr] + $oDelete.Delete + Next + $oItem = "" + $oColItems = "" + $oFolder = "" + $oNamespace = "" + If $avNotes[0] = 0 Then Return SetError(2, 0, 0) + Redim $avNotes[$avNotes[0] + 1] + Return $avNotes +EndFunc +;=============================================================================== +; +; Function Name: _OutlookModifyNote() +; Description: Get the Notes in Microsoft Outlook +; Syntax.........: _OutlookModifyNote($oOutlook, $sSubject, $sBody = "", $sNewSubject = "", $sNewBody = "", $sCategories = "", $iColor = "", $sWarningClick = "") +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen(). +; $sSubject - The Subject of the Note +; $sBody - Optional: Necessary if more than one item has the same subject, search if string is found somewhere in body. +; $sNewSubject - Optional: The new Subject +; $sNewBody - Optional: The New Body +; $sNewCategories - Optional: Categories for the note, separated by ; +; $iNewColor - Optional: The color of the Note, 0 - Blue, 1 - Green, 2 - Pink, 3 - Yellow, 4 - White +; $sWarningClick - Optional: The Entire SearchString to 'OutlookWarning2.exe', Default = None +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Illegal parameters +; @ERROR = 2 - OutlookWarning2.exe not found. +; @ERROR = 3 - Note not found. +; @ERROR = 4 - More than 1 Note found. +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-03-02 +; Modified: - +; +;=============================================================================== +Func _OutlookModifyNote($oOutlook, $sSubject, $sBody = "", $sNewSubject = "", $sNewBody = "", $sCategories = "", $iColor = "", $sWarningClick = "") + If $sWarningClick <> "" And FileExists($sWarningClick) = 0 Then + Return SetError(2, 0, 0) + Else + Run($sWarningClick) + EndIf + Local $iRc + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Local $oNamespace = $oOutlook.GetNamespace("MAPI") + Local $oFolder = $oNamespace.GetDefaultFolder($olFolderNotes) + Local $oColItems = $oFolder.Items + Local $oFilteredItems = $oColItems.Restrict('[Subject] = "' & $sSubject & '"') + $oColItems.Sort("[Subject]") + If $oFilteredItems.Count = 0 Then Return SetError(3, 0, 0) + If $oFilteredItems.Count > 1 and $sBody = "" Then Return SetError(4, 0, 0) + If $oFilteredItems.Count >= 1 Then + Local $iNumFound = 0 + For $oItem In $oFilteredItems + If StringInStr($oItem.Body,$sBody) > 0 Then $iNumFound += 1 + Next + If $iNumFound = 0 Then Return SetError(3, 0, 0) + If $iNumFound > 1 Then Return SetError(4, 0, 0) + EndIf + For $oItem In $oFilteredItems + $oItem.Body = $sNewSubject & @CRLF & $sNewBody + If $sCategories <> "" Then $oItem.Categories = $sCategories + If $iColor <> "" Then + If $iColor < 0 And $iColor > 4 Then Return SetError(1, 0, 0) + $oItem.Color = $iColor + EndIf + $oItem.Close ($olSave) + $iRc = @ERROR + Next + $oItem = "" + $oColItems = "" + $oFolder = "" + $oNamespace = "" + If $iRc = 0 Then + Return 1 + Else + Return SetError(9, 0, 0) + EndIf + Return 1 +EndFunc +;=============================================================================== +; +; Function Name: _OutlookCreateTask() +; Description: Create a task using Microsoft Outlook. +; Syntax.........: _OutlookCreateTask($oOutlook, $sSubject, $sBody = "", $sStartDate = "", $sDueDate = "", $iImportance = "", $sReminderDate = "", $sCategories = "") +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen() +; $sSubject - The Subject of the Task +; $sBody - Optional: The Body of the Task +; $sStartDate - Optional: Start date of the task +; $sDueDate - Optional: End date the Task should be complete +; $iImportance - Optional: The Importance of the task, default = $olImportanceNormal +; $sReminderDate - Optional: When you should be reminded of the task, Date and time +; $sCategories - Optional: Categories for the note, separated by ; +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-02-09 +; Modified: - +; +;=============================================================================== +Func _OutlookCreateTask($oOutlook, $sSubject, $sBody = "", $sStartDate = "", $sDueDate = "", $iImportance = "", $sReminderDate = "", $sCategories = "") + Local $iRc = 0 + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Local $oNote = $oOutlook.CreateItem($olTaskItem) + $oNote.Subject = $sSubject + $oNote.Body = $sBody + $oNote.StartDate = $sStartDate + $oNote.DueDate = $sDueDate + $oNote.Importance = $iImportance + $oNote.Categories = $sCategories + If $sReminderDate <> "" Then + $oNote.ReminderTime = $sReminderDate + $oNote.ReminderSet = True + EndIf + $oNote.Close ($olSave) + $iRc = @ERROR + If $iRc = 0 Then + Return 1 + Else + Return SetError(9, 0, 0) + EndIf +EndFunc +;=============================================================================== +; +; Function Name: _OutlookGetTasks() +; Description: Get the Tasks in Microsoft Outlook, specify Subject and/or Date Interval and/or Status to filter +; Syntax.........: _OutlookGetTasks($oOutlook, $sSubject = "", $sStartDate = "", $sEndDate = "", $sStatus = "", $sWarningClick = "") +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen(). +; $sSubject - Optional: The Subject of the Task. +; $sStartDate - Optional: Start date & time of the Task, format YYYY-MM-DD HH:MM - or what is set locally. +; $sEndDate - Optional: End date & time of the Task, format YYYY-MM-DD HH:MM - or what is set locally. +; $sStatus - Optional: The status of the Task: +; $olTaskNotStarted=0 +; $olTaskInProgress=1 +; $olTaskComplete=2 +; $olTaskWaiting=3 +; $olTaskDeferred=4 +; $sWarningClick - Optional: The Entire SearchString to 'OutlookWarning2.exe', Default = None +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Array in the following format: [1000][6] +; [0][0] - Number of items +; [0][1] - Number of items not started +; [1][0] - Subject +; [1][1] - StartDate +; [1][2] - EndDate +; [1][3] - sStatus +; [1][4] - Priority +; [1][5] - Complete +; [1][6] - PercentComplete +; [1][7] - ReminderSet +; [1][8] - ReminderMinutesBeforeStart +; [1][9] - Owner +; [1][10] - Body +; [1][11] - Date Completed +; [1][12] - Total Work in minutes +; [1][13] - Actual work in minutes +; [1][14] - Mileage +; [1][15] - Billing Information +; [1][16] - Companies +; [1][17] - Delegator +; [1][18] - Categories +; [n][n] - Item n +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Illegal parameters +; @ERROR = 2 - No tasks found +; @ERROR = 3 - More than 999 Tasks found, the first 999 tasks will be returned. +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-03-02 +; Modified: - +; +;=============================================================================== +Func _OutlookGetTasks($oOutlook, $sSubject = "", $sStartDate = "", $sEndDate = "", $sStatus = "", $sWarningClick = "") + If $sWarningClick <> "" And FileExists($sWarningClick) = 0 Then + Return SetError(2, 0, 0) + Else + Run($sWarningClick) + EndIf + Local $avTasks[1000][19], $sFilter = "", $oFilteredItems + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + $avTasks[0][0] = 0 + $avTasks[0][1] = 0 + Local $oNamespace = $oOutlook.GetNamespace("MAPI") + Local $oFolder = $oNamespace.GetDefaultFolder($olFolderTasks) + Local $oColItems = $oFolder.Items + $oColItems.Sort("[Start]") + $oColItems.IncludeRecurrences = True + If $sSubject <> "" Then + $sFilter = '[Subject] = "' & $sSubject & '"' + EndIf + If $sStartDate <> "" Then + If Not _DateIsValid($sStartDate) Then Return SetError(1, 0, 0) + If $sFilter <> "" Then $sFilter &= ' And ' + $sFilter &= '[Start] >= "' & $sStartDate & '"' + EndIf + If $sEndDate <> "" Then + If Not _DateIsValid($sEndDate) Then Return SetError(1, 0, 0) + If $sFilter <> "" Then $sFilter &= ' And ' + $sFilter &= '[Due] <= "' & $sEndDate & '"' + EndIf + If $sStatus <> "" Then + If $sFilter <> "" Then $sFilter &= ' And ' + $sFilter &= '[Status] = "' & $sStatus & '"' + EndIf + If $sFilter = "" Then + $oFilteredItems = $oColItems + Else + $oFilteredItems = $oColItems.Restrict($sFilter) + EndIf + For $oItem In $oFilteredItems + If $avTasks[0][0] = 999 Then + SetError (3) + Return $avTasks + EndIf + $avTasks[0][0] += 1 + $avTasks[$avTasks[0][0]][0] = $oItem.Subject + $avTasks[$avTasks[0][0]][1] = $oItem.StartDate + $avTasks[$avTasks[0][0]][2] = $oItem.DueDate + $avTasks[$avTasks[0][0]][3] = $oItem.Status + $avTasks[$avTasks[0][0]][4] = $oItem.Importance + $avTasks[$avTasks[0][0]][5] = $oItem.Complete + $avTasks[$avTasks[0][0]][6] = $oItem.PercentComplete + If $avTasks[$avTasks[0][0]][6] = 0 Then $avTasks[0][1] += 1 + $avTasks[$avTasks[0][0]][7] = $oItem.ReminderSet + $avTasks[$avTasks[0][0]][8] = $oItem.ReminderTime + $avTasks[$avTasks[0][0]][9] = $oItem.Owner + $avTasks[$avTasks[0][0]][10] = $oItem.Body + $avTasks[$avTasks[0][0]][11] = $oItem.DateCompleted + $avTasks[$avTasks[0][0]][12] = $oItem.TotalWork + $avTasks[$avTasks[0][0]][13] = $oItem.ActualWork + $avTasks[$avTasks[0][0]][14] = $oItem.Mileage + $avTasks[$avTasks[0][0]][15] = $oItem.BillingInformation + $avTasks[$avTasks[0][0]][16] = $oItem.Companies + $avTasks[$avTasks[0][0]][17] = $oItem.Delegator + $avTasks[$avTasks[0][0]][18] = $oItem.Categories + Next + $oItem = "" + $oColItems = "" + $oFolder = "" + $oNamespace = "" + If $avTasks[0][0] = 0 Then Return SetError(2, 0, 0) + Redim $avTasks[$avTasks[0][0] + 1][19] + Return $avTasks +EndFunc +;=============================================================================== +; +; Function Name: _OutlookDeleteTask() +; Description: Delete a Task in Microsoft Outlook, specify Subject and eventually Start Date. +; Syntax.........: _OutlookDeleteTask($oOutlook, $sSubject, $sStartDate = "", $fDeleteMultipleTasks = False, $sWarningClick = "") +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen(). +; $sSubject - The Subject of the Task. +; $sStartDate - Optional: Start date & time of the Task, format YYYY-MM-DD HH:MM - or what is set locally. +; $fDeleteMultipleTasks - Optional: Default: False, set to True to delete multiple occurences +; $sWarningClick - Optional: The Entire SearchString to 'OutlookWarning2.exe', Default = None +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Array in the following format: [1000] +; [0] - Number of items deleted +; [1] - Deleted item 1 +; [2] - Deleted item 2 +; [n] - Deleted item n +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Illegal parameters +; @ERROR = 2 - OutlookWarning2.exe not found. +; @ERROR = 3 - More than 999 Notes found matching criteria. +; @ERROR = 4 - 0 notes found +; @ERROR = 5 - More than 1 Notes found and $fDeleteMultipleFiles = False +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-03-04 +; Modified: - +; +;=============================================================================== +Func _OutlookDeleteTask($oOutlook, $sSubject, $sStartDate = "", $fDeleteMultipleTasks = False, $sWarningClick = "") + If $sWarningClick <> "" And FileExists($sWarningClick) = 0 Then + Return SetError(2, 0, 0) + Else + Run($sWarningClick) + EndIf + Local $avTasks[1000], $aoDelete[1000], $sFilter = "", $oFilteredItems + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + $avTasks[0] = 0 + Local $oNamespace = $oOutlook.GetNamespace("MAPI") + Local $oFolder = $oNamespace.GetDefaultFolder($olFolderTasks) + Local $oColItems = $oFolder.Items + $oColItems.IncludeRecurrences = True + $sFilter = '[Subject] = "' & $sSubject & '"' + If $sStartDate <> "" Then + If Not _DateIsValid($sStartDate) Then Return SetError(1, 0, 0) + If $sFilter <> "" Then $sFilter &= ' And ' + $sFilter &= '[StartDate] = "' & $sStartDate & '"' + EndIf + $oFilteredItems = $oColItems.Restrict($sFilter) + If $oFilteredItems.Count > 999 Then Return SetError(3, 0, 0) + If $oFilteredItems.Count = 0 Then Return SetError(4, 0, 0) + If $oFilteredItems.Count > 1 And $fDeleteMultipleTasks = False Then Return SetError(5, 0, 0) + For $oItem In $oFilteredItems + $avTasks[0] += 1 + $avTasks[$avTasks[0]] = $oItem.Subject & " - " & $oItem.StartDate + $aoDelete[$avTasks[0]] = $oItem + Next + For $iDeleteNr = 1 To $avTasks[0] + $oDelete = $aoDelete[$iDeleteNr] + $oDelete.Delete + Next + $oItem = "" + $oColItems = "" + $oFolder = "" + $oNamespace = "" + If $avTasks[0] = 0 Then Return SetError(2, 0, 0) + Redim $avTasks[$avTasks[0] + 1] + Return $avTasks +EndFunc +;=============================================================================== +; +; Function Name: _OutlookModifyTask() +; Description: Modify a Task in Microsoft Outlook, specify Subject and/or Start Date. +; Syntax.........: _OutlookModifyTask($oOutlook, $sSubject, $sStartDate = "", $sNewSubject = "", $sNewStartDate = "", $sDueDate = "", $iStatus = "", $iImportance = "", $fComplete = "", $iPercentComplete = "", $fReminderSet = "", $sReminderTime = "", $sOwner = "", $sBody = "", $sDateCompleted = "", $iTotalWork = "", $iActualWork = "", $sMileage = "", $sBillingInformation = "", $sCompanies = "", $sDelegator = "", $sCategories = "", $sWarningClick = "") +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen(). +; $sSubject - The Subject of the Task. +; $sStartDate - Optional: Start date & time of the Task, format YYYY-MM-DD HH:MM - or what is set locally. +; $sNewSubject - Optional: New Subject +; $sNewStartDate - Optional: New Start Date, format YYYY-MM-DD HH:MM - or what is set locally. +; $sDueDate - Optional: Due Date, format YYYY-MM-DD HH:MM - or what is set locally. +; $iStatus - Optional: $olTaskNotStarted=0 +; $olTaskInProgress=1 +; $olTaskComplete=2 +; $olTaskWaiting=3 +; $olTaskDeferred=4 +; $iImportance - Optional: $olImportanceLow=0 +; $olImportanceNormal=1 +; $olImportanceHigh=2 +; $fComplete - Optional: True or False, sets DateCompleted to actual Date and Time and PercentComplete = 100 +; $iPercentComplete - Optional: Percent complete, sets DateCompleted to actual Date and Time, Sets complete to True +; $fReminderSet - Optional: True or False +; $sReminderTime - Optional: Reminder Date, format YYYY-MM-DD HH:MM - or what is set locally. +; $sOwner - Optional: Owner +; $sBody - Optional: Body +; $sDateCompleted - Optional: Completed Date, format YYYY-MM-DD HH:MM - or what is set locally, also sets Complete = True and PercentComplete = 100 +; $iTotalWork - Optional: Total Work in minutes +; $iActualWork - Optional: Actual Work in minutes +; $sMileage - Optional: Mileage +; $sBillingInformation - Optional: Billing Information +; $sCompanies - Optional: Companies +; $sDelegator - Optional: Delegator +; $sCategories - Optional: Categories +; $sWarningClick - Optional: The Entire SearchString to 'OutlookWarning2.exe', Default = None +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Array in the following format: [1000] +; [0] - Number of items deleted +; [1] - Deleted item 1 +; [2] - Deleted item 2 +; [n] - Deleted item n +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Illegal parameters +; @ERROR = 2 - OutlookWarning2.exe not found. +; @ERROR = 4 - 0 notes found +; @ERROR = 5 - More than 1 Notes found +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-03-06 +; Modified: - +; +;=============================================================================== +Func _OutlookModifyTask($oOutlook, $sSubject, $sStartDate = "", $sNewSubject = "", $sNewStartDate = "", $sDueDate = "", $iStatus = "", $iImportance = "", $fComplete = "", $iPercentComplete = "", $fReminderSet = "", $sReminderTime = "", $sOwner = "", $sBody = "", $sDateCompleted = "", $iTotalWork = "", $iActualWork = "", $sMileage = "", $sBillingInformation = "", $sCompanies = "", $sDelegator = "", $sCategories = "", $sWarningClick = "") + If $sWarningClick <> "" And FileExists($sWarningClick) = 0 Then + Return SetError(2, 0, 0) + Else + Run($sWarningClick) + EndIf + If $sSubject = "" And $sStartDate = "" Then Return SetError(1, 0, 0) + Local $iRc = 0, $sFilter = "", $oFilteredItems + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Local $oNamespace = $oOutlook.GetNamespace("MAPI") + Local $oFolder = $oNamespace.GetDefaultFolder($olFolderTasks) + Local $oColItems = $oFolder.Items + $oColItems.IncludeRecurrences = True + $sFilter = '[Subject] = "' & $sSubject & '"' + If $sStartDate <> "" Then + If Not _DateIsValid($sStartDate) Then Return SetError(1, 0, 0) + If $sFilter <> "" Then $sFilter &= ' And ' + $sFilter &= '[StartDate] = "' & $sStartDate & '"' + EndIf + $oFilteredItems = $oColItems.Restrict($sFilter) + If $oFilteredItems.Count = 0 Then Return SetError(4, 0, 0) + If $oFilteredItems.Count > 1 Then Return SetError(5, 0, 0) + For $oItem In $oFilteredItems + If $sNewSubject <> "" Then + $oItem.Subject = $sNewSubject + EndIf + If $sNewStartDate <> "" Then + If Not _DateIsValid($sNewStartDate) Then Return SetError(1, 0, 0) + $oItem.StartDate = $sNewStartDate + EndIf + If $sDueDate <> "" Then + $oItem.DueDate = $sDueDate + EndIf + If $iStatus <> "" Then + $oItem.Status = $iStatus + EndIf + If $iImportance <> "" Then + $oItem.Importance = $iImportance + EndIf + If $fComplete <> "" Then + $oItem.Complete = $fComplete + EndIf + If $iPercentComplete <> "" Then + $oItem.PercentComplete = $iPercentComplete + EndIf + If $fReminderSet <> "" Then + $oItem.ReminderSet = $fReminderSet + EndIf + If $sReminderTime <> "" Then + $oItem.ReminderTime = $sReminderTime + EndIf + If $sOwner <> "" Then + $oItem.Owner = $sOwner + EndIf + If $sBody <> "" Then + $oItem.Body = $sBody + EndIf + If $sDateCompleted <> "" Then + If Not _DateIsValid($sDateCompleted) Then Return SetError(1, 0, 0) + $oItem.DateCompleted = $sDateCompleted + EndIf + If $iTotalWork <> "" Then + $oItem.TotalWork = $iTotalWork + EndIf + If $iActualWork <> "" Then + $oItem.ActualWork = $iActualWork + EndIf + If $sMileage <> "" Then + $oItem.Mileage = $sMileage + EndIf + If $sBillingInformation <> "" Then + $oItem.BillingInformation = $sBillingInformation + EndIf + If $sCompanies <> "" Then + $oItem.Companies = $sCompanies + EndIf + If $sDelegator <> "" Then + $oItem.Delegator = $sDelegator + EndIf + If $sCategories <> "" Then + $oItem.Categories = $sCategories + EndIf + $oItem.Close ($olSave) + $iRc = @ERROR + Next + $oItem = "" + $oColItems = "" + $oFolder = "" + $oNamespace = "" + If $iRc = 0 Then + Return 1 + Else + Return SetError(9, 0, 0) + EndIf +EndFunc +;=============================================================================== +; +; Function Name: _OutlookCreateAppointment() +; Description: Create an appointment using Microsoft Outlook. +; Syntax.........: _OutlookCreateAppointment($oOutlook, $sSubject, $sStartDate, $sEndDate = "", $sLocation = "", $fAllDayEvent = False, $sBody = "", $sReminder = 15, $sShowTimeAs = "", $iImportance = "", $iSensitivity = "", $iRecurrenceType = "", $sPatternStartDate = "", $sPatternEndDate = "", $iInterval = "", $iDayOfWeekMask = "", $iDay_MonthOfMonth_Year = "", $iInstance = "") +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen(). +; $sSubject - The Subject of the Appointment. +; $sStartDate - Start date & time of the Appointment, format YYYY-MM-DD HH:MM - or what is set locally. +; $sEndDate - Optional: End date & time of the Appointment, format YYYY-MM-DD HH:MM - or what is set locally. +; Number of minutes. If not set 30 minutes is used. +; $sLocation - Optional: The location where the meeting is going to take place. +; $fAllDayEvent - Optional: True or False(default), if set to True and the appointment is lasting for more than one day, end Date +; must be one day higher than the actual end Date. +; $sBody - Optional: The Body of the Appointment. +; $sReminder - Optional: Reminder in Minutes before start, 0 for no reminder +; $sShowTimeAs - Optional: $olBusy=2 (default), $olFree=0, $olOutOfOffice=3, $olTentative=1 +; $iImportance - Optional: $olImportanceNormal=1 (default), $olImportanceHigh=2, $olImportanceLow=0 +; $iSensitivity - Optional: $olNormal=0, $olPersonal=1, $olPrivate=2, $olConfidential=3 +; $iRecurrenceType - Optional: $olRecursDaily=0, $olRecursWeekly=1, $olRecursMonthly=2, $olRecursMonthNth=3, $olRecursYearly=5, $olRecursYearNth=6 +; $sPatternStartDate - Optional: Start Date of the Reccurent Appointment, format YYYY-MM-DD - or what is set locally. +; $sPatternEndDate - Optional: End Date of the Reccurent Appointment, format YYYY-MM-DD - or what is set locally. +; $iInterval - Optional: Interval between the Reccurent Appointment +; $iDayOfWeekMask - Optional: Add the values of the days the appointment shall occur. $olSunday=1, $olMonday=2, $olTuesday=4, $olWednesday=8, $olThursday=16, $olFriday=32, $olSaturday=64 +; $iDay_MonthOfMonth_Year - Optional: DayOfMonth or MonthOfYear, Day of the month or month of the year on which the recurring appointment or task occurs +; $iInstance - Optional: This property is only valid for recurrences of the $olRecursMonthNth and $olRecursYearNth type and allows the definition of a recurrence pattern that is only valid for the Nth occurrence, such as "the 2nd Sunday in March" pattern. The count is set numerically: 1 for the first, 2 for the second, and so on through 5 for the last. Values greater than 5 will generate errors when the pattern is saved. +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Illegal parameters +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-02-11 +; Modified: - +; +;=============================================================================== +Func _OutlookCreateAppointment($oOutlook, $sSubject, $sStartDate = "", $sEndDate = "", $sLocation = "", $fAllDayEvent = False, $sBody = "", $sReminder = 0, $sShowTimeAs = "", $iImportance = "", $iSensitivity = "", $iRecurrenceType = "", $sPatternStartDate = "", $sPatternEndDate = "", $iInterval = "", $iDayOfWeekMask = "", $iDay_MonthOfMonth_Year = "", $iInstance = "") + Local $iRc = 0 + If $fAllDayEvent = "" Then Return SetError(1, 0, 0) + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Local $oNote = $oOutlook.CreateItem($olAppointmentItem) + $oNote.Subject = $sSubject + $oNote.Location = $sLocation + $oNote.AllDayEvent = $fAllDayEvent + If Not _DateIsValid($sStartDate) Then Return SetError(1, 0, 0) + $oNote.Start = $sStartDate + If _DateIsValid($sEndDate) Then + $oNote.End = $sEndDate + Else + $oNote.Duration = Number($sEndDate) + EndIf + $oNote.Body = $sBody + If $sReminder <> 0 Then + $oNote.ReminderSet = True + $oNote.ReminderMinutesBeforeStart = $sReminder + Else + $oNote.ReminderSet = False + EndIf + $oNote.Importance = $iImportance + $oNote.BusyStatus = $sShowTimeAs + If $iSensitivity <> "" Then $oNote.Sensitivity = $iSensitivity + If $iRecurrenceType <> "" Then + Local $oRecurrent = $oNote.GetRecurrencePattern + $oRecurrent.RecurrenceType = $iRecurrenceType + If $sPatternStartDate <> "" And $sPatternEndDate <> "" Then + If $iDayOfWeekMask <> "" Then $oRecurrent.DayOfWeekMask = $iDayOfWeekMask + If Not _DateIsValid($sPatternStartDate) Then Return SetError(1, 0, 0) + If Not _DateIsValid($sPatternEndDate) Then Return SetError(1, 0, 0) + $oRecurrent.PatternStartDate = $sPatternStartDate + If $iInterval <> "" Then $oRecurrent.Interval = $iInterval + $oRecurrent.PatternEndDate = $sPatternEndDate + EndIf + If $iRecurrenceType = $olRecursMonthNth Or $iRecurrenceType = $olRecursYearNth Then + If $iRecurrenceType = $olRecursMonthNth Then + $oRecurrent.DayOfMonth = $iDay_MonthOfMonth_Year + $oRecurrent.Instance = $iInstance + Else + $oRecurrent.MonthOfYear = $iDay_MonthOfMonth_Year + $oRecurrent.Instance = $iInstance + EndIf + EndIf + EndIf + $oNote.Save + $oNote.Close ($olSave) + $iRc = @ERROR + If $iRc = 0 Then + Return 1 + Else + Return SetError(9, 0, 0) + EndIf +EndFunc +;=============================================================================== +; +; Function Name: _OutlookModifyAppointment() +; Description: Modify an appointment using Microsoft Outlook. +; Syntax.........: _OutlookModifyAppointment($oOutlook, $sSubject, $sStartDate, $sNewSubject = "", $sNewStartDate = "", $sEndDate = "", $sLocation = "", $fAllDayEvent = False, $sBody = "", $sReminder = 15, $sShowTimeAs = "", $iImportance = "", $iSensitivity = "", $iRecurrenceType = "", $sPatternStartDate = "", $sPatternEndDate = "", $iInterval = "", $iDayOfWeekMask = "", $iDay_MonthOfMonth_Year = "", $iInstance = "") +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen(). +; $sSubject - The Subject of the Appointment. +; $sStartDate - Start date & time of the Appointment, format YYYY-MM-DD HH:MM - or what is set locally. +; $sNewSubject - Optional: New Subject of the Appointment. +; $sNewStartDate - Optional: New start date & time of the Appointment, format YYYY-MM-DD HH:MM - or what is set locally. +; $sEndDate - Optional: End date & time of the Appointment, format YYYY-MM-DD HH:MM - or what is set locally. +; Number of minutes. +; $sLocation - Optional: The location where the meeting is going to take place. +; $fAllDayEvent - Optional: True or False if set to True and the appointment is lasting for more than one day, end Date +; must be one day higher than the actual end Date. +; $sBody - Optional: The Body of the Appointment. +; $sReminder - Optional: Reminder in Minutes before start, 0 for no reminder +; $sShowTimeAs - Optional: $olBusy=2, $olFree=0, $olOutOfOffice=3, $olTentative=1 +; $iImportance - Optional: $olImportanceNormal=1, $olImportanceHigh=2, $olImportanceLow=0 +; $iSensitivity - Optional: $olNormal=0, $olPersonal=1, $olPrivate=2, $olConfidential=3 +; $iRecurrenceType - Optional: $olRecursDaily=0, $olRecursWeekly=1, $olRecursMonthly=2, $olRecursMonthNth=3, $olRecursYearly=5, $olRecursYearNth=6. Remove Recurrence=-1 +; $sPatternStartDate - Optional: Start Date of the Reccurent Appointment, format YYYY-MM-DD - or what is set locally. +; $sPatternEndDate - Optional: End Date of the Reccurent Appointment, format YYYY-MM-DD - or what is set locally. +; $iInterval - Optional: Interval between the Reccurent Appointment +; $iDayOfWeekMask - Optional: Add the values of the days the appointment shall occur. $olSunday=1, $olMonday=2, $olTuesday=4, $olWednesday=8, $olThursday=16, $olFriday=32, $olSaturday=64 +; $iDay_MonthOfMonth_Year - Optional: DayOfMonth or MonthOfYear, Day of the month or month of the year on which the recurring appointment or task occurs +; $iInstance - Optional: This property is only valid for recurrences of the $olRecursMonthNth and $olRecursYearNth type and allows the definition of a recurrence pattern that is only valid for the Nth occurrence, such as "the 2nd Sunday in March" pattern. The count is set numerically: 1 for the first, 2 for the second, and so on through 5 for the last. Values greater than 5 will generate errors when the pattern is saved. +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Illegal parameters +; @ERROR = 2 - Appointment not found +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-02-23 +; Modified: - +; +;=============================================================================== +Func _OutlookModifyAppointment($oOutlook, $sSubject, $sStartDate = "", $sNewSubject = "", $sNewStartDate = "", $sEndDate = "", $sLocation = "", $fAllDayEvent = "", $sBody = "", $sReminder = "", $sShowTimeAs = "", $iImportance = "", $iSensitivity = "", $iRecurrenceType = "", $sPatternStartDate = "", $sPatternEndDate = "", $iInterval = "", $iDayOfWeekMask = "", $iDay_MonthOfMonth_Year = "", $iInstance = "") + Local $iRc = 0, $fItemFound = False, $fIsRecurring, $oRecPatt, $oOrig + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Local $oNamespace = $oOutlook.GetNamespace("MAPI") + Local $oFolder = $oNamespace.GetDefaultFolder($olFolderCalendar) + Local $oColItems = $oFolder.Items + $oColItems.Sort("[Start]") + $oColItems.IncludeRecurrences = True + Local $sFilter = '[Subject] = "' & $sSubject & '"' + Local $oFilteredItems = $oColItems.Restrict($sFilter) + For $oItem In $oFilteredItems + $fItemFound = True + $fIsRecurring = $oItem.IsRecurring + If $fIsRecurring = False Then ; ----- Non Recurring Appointment + If $oItem.Start > StringLeft($sStartDate,4) & StringMid($sStartDate,6,2) & StringMid($sStartDate,9,2) & StringMid($sStartDate,12,2) & StringMid($sStartDate,15,2) & "00" Then Return SetError(2, 0, 0) + If $oItem.Start = StringLeft($sStartDate,4) & StringMid($sStartDate,6,2) & StringMid($sStartDate,9,2) & StringMid($sStartDate,12,2) & StringMid($sStartDate,15,2) & "00" Then + If $sNewSubject <> "" Then $oItem.Subject = $sNewSubject + If $sLocation <> "" Then $oItem.Location = $sLocation + If $fAllDayEvent <> "" Then $oItem.AllDayEvent = $fAllDayEvent + If $sNewStartDate <> "" Then + If Not _DateIsValid($sNewStartDate) Then Return SetError(1, 0, 0) + $oItem.Start = $sNewStartDate + EndIf + If $sEndDate <> "" Then + If _DateIsValid($sEndDate) Then + $oItem.End = $sEndDate + Else + $oItem.Duration = Number($sEndDate) + EndIf + EndIf + If $sBody <> "" Then $oItem.Body = $sBody + If $sReminder <> "" Then + If $sReminder <> 0 Then + $oItem.ReminderSet = True + $oItem.ReminderMinutesBeforeStart = Number($sReminder) + Else + $oItem.ReminderSet = False + EndIf + EndIf + If $iImportance <> "" Then $oItem.Importance = $iImportance + If $sShowTimeAs <> "" Then $oItem.BusyStatus = $sShowTimeAs + If $iSensitivity <> "" Then $oItem.Sensitivity = $iSensitivity + If $iRecurrenceType <> "" Then + Local $oRecurrent = $oItem.GetRecurrencePattern + $oRecurrent.RecurrenceType = $iRecurrenceType + If $sPatternStartDate <> "" And $sPatternEndDate <> "" Then + If $iDayOfWeekMask <> "" Then $oRecurrent.DayOfWeekMask = $iDayOfWeekMask + If Not _DateIsValid($sPatternStartDate) Then Return SetError(1, 0, 0) + $oRecurrent.PatternStartDate = $sPatternStartDate + If Not _DateIsValid($sPatternEndDate) Then + If Not IsNumber(Number($sPatternEndDate)) Then + Return SetError(1, 0, 0) + Else + $oRecurrent.Occurrences = Number($sPatternEndDate) + EndIf + Else + $oRecurrent.PatternEndDate = $sPatternEndDate + EndIf + If $iInterval <> "" Then $oRecurrent.Interval = $iInterval + EndIf + If $iRecurrenceType = $olRecursMonthNth Or $iRecurrenceType = $olRecursYearNth Then + If $iRecurrenceType = $olRecursMonthNth Then + $oRecurrent.DayOfMonth = $iDay_MonthOfMonth_Year + $oRecurrent.Instance = $iInstance + Else + $oRecurrent.MonthOfYear = $iDay_MonthOfMonth_Year + $oRecurrent.Instance = $iInstance + EndIf + EndIf + EndIf + $oItem.Save + $oItem.Close + $iRc = @ERROR + If $iRc = 0 Or $iRc = -2147352561 Then + Return 1 + Else + Return SetError(9, 0, 0) + EndIf + EndIf + Else ; ----- Recurring Appointment, change all occurences + $oItem.GetFirst + $oRecPatt = $oItem.GetRecurrencePattern + If $sNewStartDate <> "" Then + If Not _DateIsValid($sNewStartDate) Then Return SetError(1, 0, 0) + $oRecPatt.StartTime = $sNewStartDate + EndIf + If $sEndDate <> "" Then + If _DateIsValid($sEndDate) Then + $oRecPatt.EndTime = $sEndDate + Else + $oRecPatt.Duration = Number($sEndDate) + EndIf + EndIf + $oRecPatt.Save + $oRecPatt.Close + $oOrig = $oRecPatt.Parent + If $sLocation <> "" Then $oOrig.Location = $sLocation + If $fAllDayEvent <> "" Then $oOrig.AllDayEvent = $fAllDayEvent + If $sBody <> "" Then $oOrig.Body = $sBody + If $sReminder <> "" Then + If $sReminder <> 0 Then + $oOrig.ReminderSet = True + $oOrig.ReminderMinutesBeforeStart = Number($sReminder) + Else + $oOrig.ReminderSet = False + EndIf + EndIf + If $iImportance <> "" Then $oOrig.Importance = $iImportance + If $sShowTimeAs <> "" Then $oOrig.BusyStatus = $sShowTimeAs + If $iSensitivity <> "" Then $oOrig.Sensitivity = $iSensitivity + If $iRecurrenceType <> "" Then + $oRecurrent = $oOrig.GetRecurrencePattern + $oRecurrent.RecurrenceType = $iRecurrenceType + If $sPatternStartDate <> "" And $sPatternEndDate <> "" Then + If $iDayOfWeekMask <> "" Then $oRecurrent.DayOfWeekMask = $iDayOfWeekMask + If Not _DateIsValid($sPatternStartDate) Then Return SetError(1, 0, 0) + $oRecurrent.PatternStartDate = $sPatternStartDate + If Not _DateIsValid($sPatternEndDate) Then + If Not IsNumber(Number($sPatternEndDate)) Then + Return SetError(1, 0, 0) + Else + $oRecurrent.Occurrences = Number($sPatternEndDate) + EndIf + Else + $oRecurrent.PatternEndDate = $sPatternEndDate + EndIf + If $iInterval <> "" Then $oRecurrent.Interval = $iInterval + EndIf + If $iRecurrenceType = $olRecursMonthNth Or $iRecurrenceType = $olRecursYearNth Then + If $iRecurrenceType = $olRecursMonthNth Then + $oRecurrent.DayOfMonth = $iDay_MonthOfMonth_Year + $oRecurrent.Instance = $iInstance + Else + $oRecurrent.MonthOfYear = $iDay_MonthOfMonth_Year + $oRecurrent.Instance = $iInstance + EndIf + EndIf + EndIf + $oOrig.Subject = $sNewSubject + $oOrig.Save + $oOrig.Close + $iRc = @ERROR + If $iRc = 0 Or $iRc = -2147352561 Then + Return 1 + Else + Return SetError(9, 0, 0) + EndIf + EndIf + Next + If $fItemFound = False Then Return SetError(2, 0, 0) +EndFunc +;=============================================================================== +; +; Function Name: _OutlookGetAppointments() +; Description: Get the appointments in Microsoft Outlook specify Subject and or Date Interval +; Syntax.........: _OutlookGetAppointments($oOutlook, $sSubject = "", $sStartDate = "", $sEndDate = "", $sLocation = "", $iAllDayEvent = 2, $iImportance = "") +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen(). +; $sSubject - The Subject of the Appointment. +; $sStartDate - Start date & time of the Appointment, format YYYY-MM-DD HH:MM - or what is set locally. +; $sEndDate - Optional: End date & time of the Appointment, format YYYY-MM-DD HH:MM - or what is set locally. +; $sLocation - Optional: The location where the meeting is going to take place. +; $iAllDayEvent - Optional: 0 - Part of Day, 1 - All Day, 2 - Both (default) +; $iImportance - Optional: $olImportanceNormal=1, $olImportanceHigh=2, $olImportanceLow=0 +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Array in the following format: [1000][8] +; [0][0] - Number of items +; [1][0] - Subject +; [1][1] - StartDate +; [1][2] - EndDate +; [1][3] - Location +; [1][4] - AllDayEvent +; [1][5] - Importance +; [1][6] - Body +; [1][7] - Categories +; [n][n] - Item n +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Illegal parameters +; @ERROR = 2 - No appointments found +; @ERROR = 3 - More than 999 Appointments found, the first 999 appointments will be returned +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-02-24 +; Modified: - +; +;=============================================================================== +Func _OutlookGetAppointments($oOutlook, $sSubject = "", $sStartDate = "", $sEndDate = "", $sLocation = "", $iAllDayEvent = 2, $iImportance = "") + Local $avAppointments[1000][8], $sFilter = "", $fAllDayEvent, $oFilteredItems + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Switch $iAllDayEvent + Case 0 + $fAllDayEvent = False + Case 1 + $fAllDayEvent = True + EndSwitch + $avAppointments[0][0] = 0 + Local $oNamespace = $oOutlook.GetNamespace("MAPI") + Local $oFolder = $oNamespace.GetDefaultFolder($olFolderCalendar) + Local $oColItems = $oFolder.Items + $oColItems.Sort("[Start]") + $oColItems.IncludeRecurrences = True + If $sSubject <> "" Then + $sFilter = '[Subject] = "' & $sSubject & '"' + EndIf + If $sStartDate <> "" Then + If Not _DateIsValid($sStartDate) Then Return SetError(1, 0, 0) + If $sFilter <> "" Then $sFilter &= ' And ' + $sFilter &= '[Start] >= "' & $sStartDate & '"' + EndIf + If $sEndDate <> "" Then + If Not _DateIsValid($sEndDate) Then Return SetError(1, 0, 0) + If $sFilter <> "" Then $sFilter &= ' And ' + $sFilter &= '[End] <= "' & $sEndDate & '"' + EndIf + If $sLocation <> "" Then + If $sFilter <> "" Then $sFilter &= ' And ' + $sFilter &= '[Location] = "' & $sLocation & '"' + EndIf + If $iImportance <> "" Then + If $sFilter <> "" Then $sFilter &= ' And ' + $sFilter &= '[Importance] = "' & $iImportance & '"' + EndIf + $oFilteredItems = $oColItems.Restrict($sFilter) + If $sFilter = "" Then Return SetError(1, 0, 0) + For $oItem In $oFilteredItems + $oItem.IsRecurring + If $avAppointments[0][0] = 999 Then + SetError (3) + Return $avAppointments + EndIf + If $iAllDayEvent <> 2 Then + If $fAllDayEvent = True Then + If $oItem.AllDayEvent = False Then ContinueLoop + Else + If $oItem.AllDayEvent = True Then ContinueLoop + EndIf + EndIf + $avAppointments[0][0] += 1 + $avAppointments[$avAppointments[0][0]][0] = $oItem.Subject + $avAppointments[$avAppointments[0][0]][1] = $oItem.Start + $avAppointments[$avAppointments[0][0]][2] = $oItem.End + $avAppointments[$avAppointments[0][0]][3] = $oItem.Location + $avAppointments[$avAppointments[0][0]][4] = $oItem.AllDayEvent + $avAppointments[$avAppointments[0][0]][5] = $oItem.Importance + $avAppointments[$avAppointments[0][0]][6] = $oItem.Body + $avAppointments[$avAppointments[0][0]][7] = $oItem.Categories + Next + $oItem = "" + $oColItems = "" + $oFolder = "" + $oNamespace = "" + If $avAppointments[0][0] = 0 Then Return SetError(2, 0, 0) + Redim $avAppointments[$avAppointments[0][0] + 1][8] + Return $avAppointments +EndFunc +;=============================================================================== +; +; Function Name: _OutlookCreateContact() +; Description: Create a contact using Microsoft Outlook. +; Syntax.........: _OutlookCreateContact($oOutlook, $sFirstName, $sLastName, $sEmail1Adress, $sTitle = "", $sMiddleName = "", $sSuffix = "", $sEmail1DisplayName = "", $sEmail2Adress = "", $sEmail2DisplayName = "", $sEmail3Adress = "", $sEmail3DisplayName = "", $sJobTitle = "", $sCompanyName = "", $sBody = "", $sSelectedMailingAddress = "", $sCategories = "", $sMobileTelephoneNumber = "", $sHomeTelephoneNumber = "", $sHomeAddressStreet = "", $sHomeAddressCity = "", $sHomeAddressState = "", $sHomeAddressPostalCode = "", $sHomeAddressCountry = "", $sBusinessTelephoneNumber = "", $sBusinessAddressStreet = "", $sBusinessAddressCity = "", $sBusinessAddressState = "", $sBusinessAddressPostalCode = "", $sBusinessAddressCountry = "", $sOtherTelephoneNumber = "", $sOtherAddressStreet = "", $sOtherAddressCity = "", $sOtherAddressState = "", $sOtherAddressPostalCode = "", $sOtherAddressCountry = "", $sWebPage = "", $sIMaddress = "",$sBirthday = "", $sDepartment = "", $sOfficeLocation = "", $sProfession = "", $sManagerName = "", $sAssistantName = "", $sNickName = "", $sSpouse = "", $sAnniversary = "") +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen(). +; $sFirstName - First Name +; $sLastName - Last Name +; $sEmail1Adress - E-mail address 1 +; $sTitle - Optional: Title, example: Mr, Mrs, Dr +; $sMiddleName - Optional: Middle Name +; $sSuffix - Optional: Suffix, example: I, II, III, Jr, Sr +; $sEmail1DisplayName - Optional: E-mail display name 1 +; $sEmail2Adress - Optional: E-mail address 2 +; $sEmail2DisplayName - Optional: E-mail display name 2 +; $sEmail3Adress - Optional: E-mail address 3 +; $sEmail3DisplayName - Optional: E-mail display name 3 +; $sJobTitle - Optional: Job Title +; $sCompanyName - Optional: Company Name +; $sBody - Optional: Body +; $sSelectedMailingAddress - Optional: Which address is the selected ? +; $olNone=0, $olHome=1, $olBusiness=2, $olOther=3 +; $sCategories - Optional: Categories for the note, separated by ; +; $sMobileTelephoneNumber - Optional: Mobile Phone Number +; $sHomeTelephoneNumber - Optional: Home Phone Number +; $sHomeAddressStreet - Optional: Home Address +; $sHomeAddressCity - Optional: Home City +; $sHomeAddressState - Optional: Home State +; $sHomeAddressPostalCode - Optional: Home Postal Code +; $sHomeAddressCountry - Optional: Home Country +; $sBusinessTelephoneNumber - Optional: Business Phone number +; $sBusinessAddressStreet - Optional: Business Address +; $sBusinessAddressCity - Optional: Business City +; $sBusinessAddressState - Optional: Business State +; $sBusinessAddressPostalCode - Optional: Business Postal Code +; $sBusinessAddressCountry - Optional: Business Country +; $sOtherTelephoneNumber - Optional: Other Phone Number +; $sOtherAddressStreet - Optional: Other Address +; $sOtherAddressCity - Optional: Other City +; $sOtherAddressState - Optional: Other State +; $sOtherAddressPostalCode - Optional: Other Postal Code +; $sOtherAddressCountry - Optional: Other Country +; $sWebPage - Optional: WebPage +; $sIMaddress - Optional: Instant Messenger address +; $sBirthday - Optional: Birthday, format YYYY-MM-DD - or what is set locally. +; $sDepartment - Optional: Department +; $sOfficeLocation - Optional: Office +; $sProfession - Optional: Profession +; $sManagerName - Optional: The name of your manager +; $sAssistantName - Optional: The name of your assistant +; $sNickName - Optional: Your nickname +; $sSpouse - Optional: Your Spouse +; $sAnniversary - Optional: Anniversary to remember +; +; ***** On the General Tab I have failed to find how to set Contacts and Private ***** +; +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Illegal parameters +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-02-12 +; Modified: - +; +;=============================================================================== +Func _OutlookCreateContact($oOutlook, $sFirstName, $sLastName, $sEmail1Adress, $sTitle = "", $sMiddleName = "", $sSuffix = "", $sEmail1DisplayName = "", $sEmail2Adress = "", $sEmail2DisplayName = "", $sEmail3Adress = "", $sEmail3DisplayName = "", $sJobTitle = "", $sCompanyName = "", $sBody = "", $sSelectedMailingAddress = "", $sCategories = "", $sMobileTelephoneNumber = "", $sHomeTelephoneNumber = "", $sHomeAddressStreet = "", $sHomeAddressCity = "", $sHomeAddressState = "", $sHomeAddressPostalCode = "", $sHomeAddressCountry = "", $sBusinessTelephoneNumber = "", $sBusinessAddressStreet = "", $sBusinessAddressCity = "", $sBusinessAddressState = "", $sBusinessAddressPostalCode = "", $sBusinessAddressCountry = "", $sOtherTelephoneNumber = "", $sOtherAddressStreet = "", $sOtherAddressCity = "", $sOtherAddressState = "", $sOtherAddressPostalCode = "", $sOtherAddressCountry = "", $sWebPage = "", $sIMaddress = "",$sBirthday = "", $sDepartment = "", $sOfficeLocation = "", $sProfession = "", $sManagerName = "", $sAssistantName = "", $sNickName = "", $sSpouse = "", $sAnniversary = "") + Local $iRc = 0 + If $sFirstName = "" Or $sLastName = "" Or $sEmail1Adress = "" Then Return SetError(1, 0, 0) + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Local $oContact = $oOutlook.CreateItem($olContactItem) + $oContact.FirstName = $sFirstName + $oContact.LastName = $sLastName + $oContact.Email1Address = $sEmail1Adress + $oContact.Email1AddressType = "SMTP" + If $sTitle <> "" Then $oContact.Title = $sTitle + If $sMiddleName <> "" Then $oContact.MiddleName = $sMiddleName + If $sSuffix <> "" Then $oContact.Suffix = $sSuffix + If $sEmail1DisplayName <> "" Then $oContact.Email1DisplayName = $sEmail1DisplayName + If $sEmail2Adress <> "" Then + $oContact.Email2Address = $sEmail2Adress + $oContact.Email2AddressType = "SMTP" + EndIf + If $sEmail2DisplayName <> "" Then $oContact.Email2DisplayName = $sEmail2DisplayName + If $sEmail3Adress <> "" Then + $oContact.Email3Address = $sEmail3Adress + $oContact.Email3AddressType = "SMTP" + EndIf + If $sEmail3DisplayName <> "" Then $oContact.Email3DisplayName = $sEmail3DisplayName + If $sJobTitle <> "" Then $oContact.JobTitle = $sJobTitle + If $sCompanyName <> "" Then $oContact.CompanyName = $sCompanyName + If $sBody <> "" Then $oContact.Body = $sBody + If $sSelectedMailingAddress <> "" Then $oContact.SelectedMailingAddress = $sSelectedMailingAddress + If $sCategories <> "" Then $oContact.Categories = $sCategories + If $sMobileTelephoneNumber <> "" Then $oContact.MobileTelephoneNumber = $sMobileTelephoneNumber + If $sHomeTelephoneNumber <> "" Then $oContact.HomeTelephoneNumber = $sHomeTelephoneNumber + If $sHomeAddressStreet <> "" Then $oContact.HomeAddressStreet = $sHomeAddressStreet + If $sHomeAddressCity <> "" Then $oContact.HomeAddressCity = $sHomeAddressCity + If $sHomeAddressState <> "" Then $oContact.HomeAddressState = $sHomeAddressState + If $sHomeAddressPostalCode <> "" Then $oContact.HomeAddressPostalCode = $sHomeAddressPostalCode + If $sHomeAddressCountry <> "" Then $oContact.HomeAddressCountry = $sHomeAddressCountry + If $sBusinessTelephoneNumber <> "" Then $oContact.BusinessTelephoneNumber = $sBusinessTelephoneNumber + If $sBusinessAddressStreet <> "" Then $oContact.BusinessAddressStreet = $sBusinessAddressStreet + If $sBusinessAddressCity <> "" Then $oContact.BusinessAddressCity = $sBusinessAddressCity + If $sBusinessAddressState <> "" Then $oContact.BusinessAddressState = $sBusinessAddressState + If $sBusinessAddressPostalCode <> "" Then $oContact.BusinessAddressPostalCode = $sBusinessAddressPostalCode + If $sBusinessAddressCountry <> "" Then $oContact.BusinessAddressCountry = $sBusinessAddressCountry + If $sOtherTelephoneNumber <> "" Then $oContact.OtherTelephoneNumber = $sOtherTelephoneNumber + If $sOtherAddressStreet <> "" Then $oContact.OtherAddressStreet = $sOtherAddressStreet + If $sOtherAddressCity <> "" Then $oContact.OtherAddressCity = $sOtherAddressCity + If $sOtherAddressState <> "" Then $oContact.OtherAddressState = $sOtherAddressState + If $sOtherAddressPostalCode <> "" Then $oContact.OtherAddressPostalCode = $sOtherAddressPostalCode + If $sOtherAddressCountry <> "" Then $oContact.OtherAddressCountry = $sOtherAddressCountry + If $sWebPage <> "" Then $oContact.WebPage = $sWebPage + If $sIMaddress <> "" Then $oContact.IMaddress = $sIMaddress + If $sBirthday <> "" Then $oContact.Birthday = $sBirthday + If $sDepartment <> "" Then $oContact.Department = $sDepartment + If $sOfficeLocation <> "" Then $oContact.OfficeLocation = $sOfficeLocation + If $sProfession <> "" Then $oContact.Profession = $sProfession + If $sManagerName <> "" Then $oContact.ManagerName = $sManagerName + If $sAssistantName <> "" Then $oContact.AssistantName = $sAssistantName + If $sNickName <> "" Then $oContact.NickName = $sNickName + If $sSpouse <> "" Then $oContact.Spouse = $sSpouse + If $sAnniversary <> "" Then $oContact.Anniversary = $sAnniversary + $oContact.Close ($olSave) + $iRc = @ERROR + If $iRc = 0 Then + Return 1 + Else + Return SetError(9, 0, 0) + EndIf +EndFunc +;=============================================================================== +; +; Function Name: _OutlookGetContacts() +; Description: Get contacts using Microsoft Outlook, returning an array of all information +; Syntax.........: _OutlookGetContacts($oOutlook, $sFirstName = "", $sLastName = "", $sEmail1Adress = "", $fSearchPart = False, $fFullList = False, $sWarningClick = "") +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen(). +; $sFirstName - Optional: First Name +; $sLastName - Optional: Last Name +; $sEmail1Adress - Optional: E-mail address 1 +; fSearchPart - Optional: Default: False, True if match part of the string +; fFullList - Optional: Default: False, If False, only return Small array. +; $sWarningClick - Optional: The Entire SearchString to 'OutlookWarning2.exe', Default = None +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Array in the following format: [1000][5] +; [0][0] - Total Number of items +; [1][0] - First Name +; [1][1] - Last Name +; [1][2] - E-mail address 1 +; [1][3] - E-mail address 2 +; [1][4] - Mobile Phone Number +; [n][n] - Item n +; - Array in the following format: [1000][46] +; [0][0] - Total Number of items +; [1][0] - First Name +; [1][1] - Last Name +; [1][2] - E-mail address 1 +; [1][3] - Title, example: Mr, Mrs, Dr +; [1][4] - Middle Name +; [1][5] - Suffix, example: I, II, III, Jr, Sr +; [1][6] - E-mail display name 1 +; [1][7] - E-mail address 2 +; [1][8] - E-mail display name 2 +; [1][9] - E-mail address 3 +; [1][10] - E-mail display name 3 +; [1][11] - Job Title +; [1][12] - Company Name +; [1][13] - Body +; [1][14] - Which address is the selected ? +; $olNone=0, $olHome=1, $olBusiness=2, $olOther=3 +; [1][15] - Categories for the note, separated by ; +; [1][16] - Mobile Phone Number +; [1][17] - Home Phone Number +; [1][18] - Home Address +; [1][19] - Home City +; [1][20] - Home State +; [1][21] - Home Postal Code +; [1][22] - Home Country +; [1][23] - Business Phone number +; [1][24] - Business Address +; [1][25] - Business City +; [1][26] - Business State +; [1][27] - Business Postal Code +; [1][28] - Business Country +; [1][29] - Other Phone Number +; [1][30] - Other Address +; [1][31] - Other City +; [1][32] - Other State +; [1][33] - Other Postal Code +; [1][34] - Other Country +; [1][35] - WebPage +; [1][36] - Instant Messenger address +; [1][37] - Birthday, format YYYY-MM-DD - or what is set locally. +; [1][38] - Department +; [1][39] - Office +; [1][40] - Profession +; [1][41] - The name of your manager +; [1][42] - The name of your assistant +; [1][43] - Your nickname +; [1][44] - Your Spouse +; [1][45] - Anniversary to remember +; [n][n] - Item n +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Illegal parameters +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-03-04 +; Modified: - +; +;=============================================================================== +Func _OutlookGetContacts($oOutlook, $sFirstName = "", $sLastName = "", $sEmail1Adress = "", $fSearchPart = False, $fFullList = False, $sWarningClick = "") + If $sWarningClick <> "" And FileExists($sWarningClick) = 0 Then + Return SetError(2, 0, 0) + Else + Run($sWarningClick) + EndIf + ;Local $oSecurityManager = ObjCreate("AddinExpress.Outlook.SecurityManager") + ;msgbox(0,"SM",IsObj($oSecurityManager)) + ;$oSecurityManager.DisableOOMWarnings = True + Local $iRc = 0, $iArraySize + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Local $oNamespace = $oOutlook.GetNamespace("MAPI") + Local $oFolder = $oNamespace.GetDefaultFolder($olFolderContacts) + Local $oColItems = $oFolder.Items + Local $iNumOfContacts = $oColItems.Count + If $fFullList = True Then + $iArraySize = 46 + Else + $iArraySize = 5 + EndIf + Local $asContacts[1000][$iArraySize], $sTemp + $asContacts[0][0] = 0 +; Msgbox(0,"antal",$iNumOfContacts) + For $iNum = 1 to $iNumOfContacts + ; Msgbox(0,"antal",$iNum & " / " & $iNumOfContacts) + If $oColItems.Item($iNum).Class <> $olContact Then ContinueLoop + If $sFirstName <> "" Then + If $fSearchPart = False Then + If $sFirstName <> $oColItems.Item($iNum).FirstName Then ContinueLoop + Else + If StringInStr($oColItems.Item($iNum).FirstName,$sFirstName) = 0 Then ContinueLoop + EndIf + EndIf + If $sLastName <> "" Then + If $fSearchPart = False Then + If $sLastName <> $oColItems.Item($iNum).LastName Then ContinueLoop + Else + If StringInStr($oColItems.Item($iNum).LastName,$sLastName) = 0 Then ContinueLoop + EndIf + EndIf + If $sEmail1Adress <> "" Then + $sTemp = $oColItems.Item($iNum).Email1Address + If $fSearchPart = False Then + If $sEmail1Adress <> $sTemp Then ContinueLoop + Else + If StringInStr($sTemp,$sEmail1Adress) = 0 Then ContinueLoop + EndIf + EndIf + $asContacts[0][0] += 1 + If $fFullList = False Then + $asContacts[$asContacts[0][0]][0] = $oColItems.Item($iNum).FirstName + $asContacts[$asContacts[0][0]][1] = $oColItems.Item($iNum).LastName + $asContacts[$asContacts[0][0]][2] = $oColItems.Item($iNum).Email1Address + $asContacts[$asContacts[0][0]][3] = $oColItems.Item($iNum).Email2Address + $asContacts[$asContacts[0][0]][4] = $oColItems.Item($iNum).MobileTelephoneNumber + Else + $asContacts[$asContacts[0][0]][3] = $oColItems.Item($iNum).Title + $asContacts[$asContacts[0][0]][4] = $oColItems.Item($iNum).MiddleName + $asContacts[$asContacts[0][0]][5] = $oColItems.Item($iNum).Suffix + $asContacts[$asContacts[0][0]][6] = $oColItems.Item($iNum).Email1DisplayName + $asContacts[$asContacts[0][0]][7] = $oColItems.Item($iNum).Email2Address + $asContacts[$asContacts[0][0]][8] = $oColItems.Item($iNum).Email2DisplayName + $asContacts[$asContacts[0][0]][9] = $oColItems.Item($iNum).Email3Address + $asContacts[$asContacts[0][0]][10] = $oColItems.Item($iNum).Email3DisplayName + $asContacts[$asContacts[0][0]][11] = $oColItems.Item($iNum).JobTitle + $asContacts[$asContacts[0][0]][12] = $oColItems.Item($iNum).CompanyName + $asContacts[$asContacts[0][0]][13] = $oColItems.Item($iNum).Body + $asContacts[$asContacts[0][0]][14] = $oColItems.Item($iNum).SelectedMailingAddress + $asContacts[$asContacts[0][0]][15] = $oColItems.Item($iNum).Categories + $asContacts[$asContacts[0][0]][16] = $oColItems.Item($iNum).MobileTelephoneNumber + $asContacts[$asContacts[0][0]][17] = $oColItems.Item($iNum).HomeTelephoneNumber + $asContacts[$asContacts[0][0]][18] = $oColItems.Item($iNum).HomeAddressStreet + $asContacts[$asContacts[0][0]][19] = $oColItems.Item($iNum).HomeAddressCity + $asContacts[$asContacts[0][0]][20] = $oColItems.Item($iNum).HomeAddressState + $asContacts[$asContacts[0][0]][21] = $oColItems.Item($iNum).HomeAddressPostalCode + $asContacts[$asContacts[0][0]][22] = $oColItems.Item($iNum).HomeAddressCountry + $asContacts[$asContacts[0][0]][23] = $oColItems.Item($iNum).BusinessTelephoneNumber + $asContacts[$asContacts[0][0]][24] = $oColItems.Item($iNum).BusinessAddressStreet + $asContacts[$asContacts[0][0]][25] = $oColItems.Item($iNum).BusinessAddressCity + $asContacts[$asContacts[0][0]][26] = $oColItems.Item($iNum).BusinessAddressState + $asContacts[$asContacts[0][0]][27] = $oColItems.Item($iNum).BusinessAddressPostalCode + $asContacts[$asContacts[0][0]][28] = $oColItems.Item($iNum).BusinessAddressCountry + $asContacts[$asContacts[0][0]][29] = $oColItems.Item($iNum).OtherTelephoneNumber + $asContacts[$asContacts[0][0]][30] = $oColItems.Item($iNum).OtherAddressStreet + $asContacts[$asContacts[0][0]][31] = $oColItems.Item($iNum).OtherAddressCity + $asContacts[$asContacts[0][0]][32] = $oColItems.Item($iNum).OtherAddressState + $asContacts[$asContacts[0][0]][33] = $oColItems.Item($iNum).OtherAddressPostalCode + $asContacts[$asContacts[0][0]][34] = $oColItems.Item($iNum).OtherAddressCountry + $asContacts[$asContacts[0][0]][35] = $oColItems.Item($iNum).WebPage + $asContacts[$asContacts[0][0]][36] = $oColItems.Item($iNum).IMaddress + $asContacts[$asContacts[0][0]][37] = $oColItems.Item($iNum).Birthday + $asContacts[$asContacts[0][0]][38] = $oColItems.Item($iNum).Department + $asContacts[$asContacts[0][0]][39] = $oColItems.Item($iNum).OfficeLocation + $asContacts[$asContacts[0][0]][40] = $oColItems.Item($iNum).Profession + $asContacts[$asContacts[0][0]][41] = $oColItems.Item($iNum).ManagerName + $asContacts[$asContacts[0][0]][42] = $oColItems.Item($iNum).AssistantName + $asContacts[$asContacts[0][0]][43] = $oColItems.Item($iNum).NickName + $asContacts[$asContacts[0][0]][44] = $oColItems.Item($iNum).Spouse + $asContacts[$asContacts[0][0]][45] = $oColItems.Item($iNum).Anniversary + EndIf + Next + $iRc = @ERROR + Redim $asContacts[$asContacts[0][0] + 1][$iArraySize] + If $iRc = 0 Then + ;$oSecurityManager.DisableOOMWarnings = True + Return $asContacts + Else + Return SetError(9, 0, 0) + EndIf +EndFunc +;=============================================================================== +; +; Function Name: _OutlookCreateDistList() +; Description: Create a distribution and DL member using Microsoft Outlook, if Distribution list exist, create only DL member +; Syntax.........: _OutlookCreateDistList($oOutlook, $sDistList, $sFullName, $sEmailAddress, $sNotes = "", $fSameFullName = False , $sWarningClick = "") +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen(). +; $sDistList - Name of Distribution list +; $sFullName - Full name of person in distribution list +; $sEmailAddress - E-mail of person in distribution list or "AddMembers" - Adds people from contacts or global address list +; $sNotes - Optional: Notes about the distribution list +; $fSameFullName - Optional: Accept Multiple persons with same name in Distribution List, Default = False +; $sWarningClick - Optional: The Entire SearchString to 'OutlookWarning2.exe', Default = None +; +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Illegal parameters +; @ERROR = 2 - OutlookWarning2.exe not found. +; @ERROR = 3 - $fSameFullName = False AND $sFullName already found in distrbution list +; @ERROR = 4 - $sEmailAddress already found in distributionslist +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-02-17 +; Modified: - +; +;=============================================================================== +Func _OutlookCreateDistList($oOutlook, $sDistList, $sFullName, $sEmailAddress, $sNotes = "", $fSameFullName = False , $sWarningClick = "") + Local $iRc = 0, $oMemberName, $oMemberAddress, $oRecipients + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + If $sWarningClick <> "" And FileExists($sWarningClick) = 0 Then + Return SetError(2, 0, 0) + Else + Run($sWarningClick) + EndIf + Local $oNameSpace = $oOutlook.GetNamespace("MAPI") + Local $oMailItem = $oOutlook.CreateItem($olMailItem) + Local $oDistList = $oOutlook.CreateItem($olDistributionListItem) + Local $oContacts = $oNameSpace.GetDefaultFolder($olFolderContacts) + + Local $oDistListItem = $oContacts.Items( $sDistList ) + If @ERROR = -2147352567 Then ; Add Group and member + SetError(0, 0, 0) + If $sEmailAddress = "AddMembers" Then + $oRecipients = $oMailItem.Recipients + $oDistList.DLName = $sDistList + $oDistList.Body = $sNotes + $oRecipients.Add ($sFullName) + $oRecipients.ResolveAll + $oDistList.AddMembers ($oRecipients) + $oDistList.Save + $oDistList.Close ($olSave) + $iRc = @ERROR + Else + $oRecipients = $oOutlook.Session.CreateRecipient($sFullName & " <" & $sEmailAddress & ">") + $oRecipients.Resolve + $oDistList.AddMember ($oRecipients) + $oDistList.DLName = $sDistList + $oDistList.Body = $sNotes + $oDistList.Save + $oDistList.Close ($olSave) + $iRc = @ERROR + EndIf + Else ; Add Member only + SetError(0, 0, 0) + If $sEmailAddress = "AddMembers" Then + For $iMember = 1 to $oDistListItem.MemberCount + $oMemberName = $oDistListItem.GetMember($iMember).Name + If $fSameFullName = False and $oMemberName = $sFullName Then Return SetError(3, 0, 0) + Next + $oRecipients = $oMailItem.Recipients + $oRecipients.Add ($sFullName) + $oRecipients.ResolveAll + $oDistListItem.AddMembers ($oRecipients) + $oDistListItem.Save + $oDistListItem.Close ($olSave) + $iRc = @ERROR + Else + For $iMember = 1 to $oDistListItem.MemberCount + $oMemberName = $oDistListItem.GetMember($iMember).Name + $oMemberAddress = $oDistListItem.GetMember($iMember).Address + If $fSameFullName = False and $oMemberName = $sFullName Then Return SetError(3, 0, 0) + If $oMemberAddress = $sEmailAddress Then Return SetError(4, 0, 0) + Next + $oRecipients = $oOutlook.Session.CreateRecipient($sFullName & " <" & $sEmailAddress & ">") + $oRecipients.Resolve + $oDistListItem.AddMember ($oRecipients) + $oDistListItem.Save + $oDistListItem.Close ($olSave) + $iRc = @ERROR + EndIf + EndIf + If $iRc = 0 Then + Return 1 + Else + Return SetError(9, 0, 0) + EndIf +EndFunc +;=============================================================================== +; +; Function Name: _OutlookGetDistLists() +; Description: Get Distribution lists and their members using Microsoft Outlook, returning an array of all information +; Syntax.........: _OutlookGetDistLists($oOutlook, $sDistListName = "", $sFullName = "", $sEmailAddress = "", $fSearchPart = False, $sWarningClick = "") +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen(). +; $sDistListName - Optional: Distribution list Name +; $sFullName - Optional: Full Name +; $sEmailAddress - Optional: E-mail address +; fSearchPart - Optional: Default: False +; $sWarningClick - Optional: The Entire SearchString to 'OutlookWarning2.exe', Default = None +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Array in the following format: [1000][3] +; [0][0] - Total Number of items +; [1][0] - Distribution List +; [1][1] - Full Name +; [1][2] - E-mail address +; [n][n] - Item n +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Illegal parameters +; @ERROR = 2 - OutlookWarning2.exe not found. +; @ERROR = 3 - Both Distribution list And (Full name or E-mail address specified). +; @ERROR = 4 - More than 999 records found, the first 999 records will be returned +; @ERROR = 5 - No distribution list found. +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-03-04 +; Modified: - +; +;=============================================================================== +Func _OutlookGetDistLists($oOutlook, $sDistListName = "", $sFullName = "", $sEmailAddress = "", $fSearchPart = False, $sWarningClick = "") + If $sWarningClick <> "" And FileExists($sWarningClick) = 0 Then + Return SetError(2, 0, 0) + Else + Run($sWarningClick) + EndIf + If $sDistListName <> "" And ($sFullName <> "" or $sEmailAddress <> "") Then Return SetError(3, 0, 0) + Local $iRc = 0 + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Local $oNamespace = $oOutlook.GetNamespace("MAPI") + Local $oFolder = $oNamespace.GetDefaultFolder($olFolderContacts) + Local $oColItems = $oFolder.Items + Local $iNumOfDistLists = $oColItems.Count + Local $asDistList[1000][3] + $asDistList[0][0] = 0 + For $iNum = 1 to $iNumOfDistLists + If $oColItems.Item($iNum).Class <> $olDistributionList Then ContinueLoop + If $sDistListName <> "" Then + If $fSearchPart = False Then + If $sDistListName <> $oColItems.Item($iNum).DLName Then ContinueLoop + Else + If StringInStr($oColItems.Item($iNum).DLName,$sDistListName) = 0 Then ContinueLoop + EndIf + EndIf + If $asDistList[0][0] = 999 Then + SetError (4) + Return $asDistList + EndIf + For $iMember = 1 to $oColItems.Item($iNum).MemberCount + If $sFullName <> "" Then + If $fSearchPart = False Then + If $sFullName <> $oColItems.Item($iNum).GetMember($iMember).Name Then ContinueLoop + Else + If StringInStr($oColItems.Item($iNum).GetMember($iMember).Name,$sFullName) = 0 Then ContinueLoop + EndIf + EndIf + If $sEmailAddress <> "" Then + If $fSearchPart = False Then + If $sEmailAddress <> $oColItems.Item($iNum).GetMember($iMember).Address Then ContinueLoop + Else + If StringInStr($oColItems.Item($iNum).GetMember($iMember).Address,$sEmailAddress) = 0 Then ContinueLoop + EndIf + EndIf + $asDistList[0][0] += 1 + $asDistList[$asDistList[0][0]][0] = $oColItems.Item($iNum).DLName + $asDistList[$asDistList[0][0]][1] = $oColItems.Item($iNum).GetMember($iMember).Name + $asDistList[$asDistList[0][0]][2] = $oColItems.Item($iNum).GetMember($iMember).Address + Next + Next + $iRc = @ERROR + Redim $asDistList[$asDistList[0][0] + 1][3] + If $asDistList[0][0] = 0 Then Return SetError(5, 0, 0) + If $iRc = 0 Then + Return $asDistList + Else + Return SetError(9, 0, 0) + EndIf +EndFunc +;=============================================================================== +; +; Function Name: _OutlookDeleteDistListMember() +; Description: Delete Distribution list member +; Syntax.........: _OutlookDeleteDistListMember($oOutlook, $sDistListName, $sFullName = "", $sEmailAddress = "", $sWarningClick = "") +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen(). +; $sDistListName - Optional: Distribution list Name +; $sFullName - Optional: Full Name +; $sEmailAddress - Optional: E-mail address +; $sWarningClick - Optional: The Entire SearchString to 'OutlookWarning2.exe', Default = None +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Return 1 +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Illegal parameters +; @ERROR = 2 - OutlookWarning2.exe not found. +; @ERROR = 3 - Distribution list not found. +; @ERROR = 4 - Distribution list member not found. +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-03-09 +; Modified: - +; +;=============================================================================== +Func _OutlookDeleteDistListMember($oOutlook, $sDistListName = "", $sFullName = "", $sEmailAddress = "", $sWarningClick = "") + If $sWarningClick <> "" And FileExists($sWarningClick) = 0 Then + Return SetError(2, 0, 0) + Else + Run($sWarningClick) + EndIf + Local $iRc = 0, $fDistListFound = False, $fDistListMemberFound = False + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Local $oNamespace = $oOutlook.GetNamespace("MAPI") + Local $oFolder = $oNamespace.GetDefaultFolder($olFolderContacts) + Local $oColItems = $oFolder.Items + Local $iNumOfDistLists = $oColItems.Count + For $iNum = 1 to $iNumOfDistLists + If $oColItems.Item($iNum).Class <> $olDistributionList Then ContinueLoop + If $sDistListName <> $oColItems.Item($iNum).DLName Then ContinueLoop + $fDistListFound = True + For $iMember = 1 to $oColItems.Item($iNum).MemberCount + If ($sFullName <> "") And ($sEmailAddress <> "") Then + If $sFullName = $oColItems.Item($iNum).GetMember($iMember).Name And $sEmailAddress = $oColItems.Item($iNum).GetMember($iMember).Address Then + $fDistListMemberFound = True + $oColItems.Item($iNum).GetMember($iMember).resolve + $oColItems.Item($iNum).RemoveMember ($oColItems.Item($iNum).GetMember($iMember)) + $oColItems.Item($iNum).Save + $oColItems.Item($iNum).Close ($olSave) + Exitloop 2 + Else + ContinueLoop + EndIf + Else + If $sFullName <> "" Then + If $sFullName = $oColItems.Item($iNum).GetMember($iMember).Name Then + $fDistListMemberFound = True + $oColItems.Item($iNum).GetMember($iMember).resolve + $oColItems.Item($iNum).RemoveMember ($oColItems.Item($iNum).GetMember($iMember)) + $oColItems.Item($iNum).Save + $oColItems.Item($iNum).Close ($olSave) + Exitloop 2 + Else + ContinueLoop + EndIf + Else + If $sEmailAddress = $oColItems.Item($iNum).GetMember($iMember).Address Then + $fDistListMemberFound = True + $oColItems.Item($iNum).GetMember($iMember).resolve + $oColItems.Item($iNum).RemoveMember ($oColItems.Item($iNum).GetMember($iMember)) + $oColItems.Item($iNum).Save + $oColItems.Item($iNum).Close ($olSave) + Exitloop 2 + Else + ContinueLoop + EndIf + EndIf + EndIf + Next + Next + $iRc = @ERROR + If $fDistListFound = False Then Return SetError(3, 0, 0) + If $fDistListMemberFound = False Then Return SetError(4, 0, 0) + If $iRc = 0 Then + Return 1 + Else + Return SetError(9, 0, 0) + EndIf +EndFunc +;=============================================================================== +; +; Function Name: _OutlookDeleteDistList() +; Description: Delete Distribution list +; Syntax.........: _OutlookDeleteDistList($oOutlook, $sDistListName) +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen(). +; $sDistListName - Distribution list Name +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Return 1 +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Distribution list not found. +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-03-09 +; Modified: - +; +;=============================================================================== +Func _OutlookDeleteDistList($oOutlook, $sDistListName) + Local $iRc = 0, $fDistListFound = False + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Local $oNamespace = $oOutlook.GetNamespace("MAPI") + Local $oFolder = $oNamespace.GetDefaultFolder($olFolderContacts) + Local $oColItems = $oFolder.Items + Local $iNumOfDistLists = $oColItems.Count + For $iNum = 1 to $iNumOfDistLists + If $oColItems.Item($iNum).Class <> $olDistributionList Then ContinueLoop + If $sDistListName <> $oColItems.Item($iNum).DLName Then ContinueLoop + $fDistListFound = True + $oColItems.Item($iNum).Delete + ExitLoop + Next + $iRc = @ERROR + If $fDistListFound = False Then Return SetError(1, 0, 0) + If $iRc = 0 Then + Return 1 + Else + Return SetError(9, 0, 0) + EndIf +EndFunc +;=============================================================================== +; +; Function Name: _OutlookModifyDistList() +; Description: Modify Distribution list +; Syntax.........: _OutlookModifyDistList($oOutlook, $sDistListName, $sNewDistListName = "", $sNotes = "", $fMergeWithCurrentNotes = False, $sCategories = "", $sWarningClick = "") +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen(). +; $sDistListName - Optional: Distribution list Name +; $sFullName - Optional: Full Name +; $sEmailAddress - Optional: E-mail address +; $sWarningClick - Optional: The Entire SearchString to 'OutlookWarning2.exe', Default = None +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Return 1 +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Illegal parameters +; @ERROR = 2 - OutlookWarning2.exe not found. +; @ERROR = 3 - Distribution list not found. +; @ERROR = 4 - Distribution list member not found. +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-03-09 +; Modified: - +; +;=============================================================================== +Func _OutlookModifyDistList($oOutlook, $sDistListName, $sNewDistListName = "", $sNotes = "", $fMergeWithCurrentNotes = False, $sCategories = "", $fMergeWithCurrentCategories = False, $sWarningClick = "") + If $sWarningClick <> "" And FileExists($sWarningClick) = 0 Then + Return SetError(2, 0, 0) + Else + Run($sWarningClick) + EndIf + Local $iRc = 0, $fDistListFound = False, $sTemp + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Local $oNamespace = $oOutlook.GetNamespace("MAPI") + Local $oFolder = $oNamespace.GetDefaultFolder($olFolderContacts) + Local $oColItems = $oFolder.Items + Local $iNumOfDistLists = $oColItems.Count + For $iNum = 1 to $iNumOfDistLists + If $oColItems.Item($iNum).Class <> $olDistributionList Then ContinueLoop + If $sDistListName <> $oColItems.Item($iNum).DLName Then ContinueLoop + $fDistListFound = True + If $sNewDistListName <> "" Then + + ;$oColItems.Item($iNum).DLName = $sNewDistListName + $oColItems.Item($iNum).Subject = "Kalle" + EndIf + If $sNotes <> "" Then + If $fMergeWithCurrentNotes = True Then + + $sTemp = $oColItems.Item($iNum).Body + $oColItems.Item($iNum).Body = $sTemp & @CRLF & $sNotes + Else + $oColItems.Item($iNum).Body = $sNotes + EndIf + EndIf + If $sCategories <> "" Then + If $fMergeWithCurrentCategories = True Then + $sTemp = $oColItems.Item($iNum).Categories + $oColItems.Item($iNum).Categories = $sTemp & @CRLF & $sCategories + Else + $oColItems.Item($iNum).Categories = $sCategories + EndIf + EndIf + $oColItems.Item($iNum).Save + $oColItems.Item($iNum).Close ($olSave) + ExitLoop + Next + $iRc = @ERROR + If $fDistListFound = False Then Return SetError(3, 0, 0) + If $iRc = 0 Then + Return 1 + Else + Return SetError(9, 0, 0) + EndIf +EndFunc +;=============================================================================== +; +; Function Name: _OutlookFolderExist() +; Description: Check if an Outlook folder exist +; Syntax.........: _OutlookFolderExist($oOutlook, $sFolder) +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen(). +; $sFolder - The Name of the Folder +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Return 1 +; On Failure - Return 0, and sets @ERROR > 0 +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-03-11 +; Modified: +; +;=============================================================================== +Func _OutlookFolderExist($oOutlook, $sFolder) + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Local $oNamespace = $oOutlook.GetNamespace("MAPI") + If StringRight($sFolder,1) = "\" Then $sFolder = StringLeft($sFolder,StringLen($sFolder) - 1) + Local $sSubFolderParts = StringSplit ( $sFolder, "\") + Local $oFolder = $oNamespace.GetDefaultFolder($sSubFolderParts[1]) + Local $iFolderFound = 0 + If IsObj($oFolder) = 0 Then + Return 0 + Else + $iFolderFound = 1 + EndIf + Local $sRootFolderName = $oFolder.Name + If $sSubFolderParts[0] > 1 Then + $iFolderFound = _OutlookFindRootFolder($oFolder,$sRootFolderName,StringMid($sFolder,StringInStr($sFolder,"\")+ 1)) + EndIf + If $iFolderFound = 0 Then Return 0 + Return 1 +EndFunc +;=============================================================================== +; +; Function Name: _OutlookFolderAdd() +; Description: Add a new Outlook folder +; Syntax.........: _OutlookFolderAdd($oOutlook, $sFolder) +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen(). +; $sFolder - The Name of the Folder +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Return 1 +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Folder does already exist. +; @ERROR = 2 - Couldn't find root folder. +; @ERROR = 3 - Error when creating folder. +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-03-11 +; Modified: +; +;=============================================================================== +Func _OutlookFolderAdd($oOutlook, $sFolder) + If StringRight($sFolder,1) = "\" Then $sFolder = StringLeft($sFolder,StringLen($sFolder) - 1) + If _OutlookFolderExist($oOutlook, $sFolder) Then Return SetError(1, 0, 0) + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Local $oNamespace = $oOutlook.GetNamespace("MAPI") + Local $sSubFolderParts = StringSplit ( $sFolder, "\") + Local $oFolder = $oNamespace.GetDefaultFolder($sSubFolderParts[1]) + Local $fSubFolderExist = False + If IsObj($oFolder) = 0 Then Return SetError(2, 0, 0) + Local $sFolderName = $oFolder.Name + For $iLevel = 2 to $sSubFolderParts[0] + $sFolderName &= "\" & $sSubFolderParts[$iLevel] + If _OutlookFolderExist($oOutlook, $sFolderName) Then ContinueLoop + $fSubFolderExist = False + + For $oSubFolder in $oFolder.Folders + If StringMid($sFolderName,StringInStr($sFolderName,"\",0,-1) + 1) = $oSubFolder.Name Then + $fSubFolderExist = True + ExitLoop + EndIf + Next + If $fSubFolderExist = True Then + $oFolder = $oSubFolder + Else + $oFolder.Folders.Add($sSubFolderParts[$iLevel]) + $oFolder = $oSubFolder + EndIf + Next + If _OutlookFolderExist($oOutlook, $sFolder) = 0 Then Return SetError(3, 0, 0) + Return 1 +EndFunc +;=============================================================================== +; +; Function Name: _OutlookFolderDelete() +; Description: Delete an Outlook folder +; Syntax.........: _OutlookFolderDelete($oOutlook, $sFolder, $fDeleteSubFolders = False) +; Parameter(s): $oOutlook - Outlook object opened by a preceding call to _OutlookOpen(). +; $sFolder - The Name of the Folder +; $fDeleteSubFolders - Optional: Delete existing subfolder as well, default = False +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Return 1 +; On Failure - Returns 0 and sets @ERROR > 0 +; @ERROR = 1 - Folder doesn't exist. +; @ERROR = 2 - Error when deleting folder. +; @ERROR = 3 - Subfolders found, and $fDeleteSubFolders = False +; @ERROR = 9 - ObjEvent error. +; Author(s): Wooltown +; Created: 2009-03-11 +; Modified: +; +;=============================================================================== +Func _OutlookFolderDelete($oOutlook, $sFolder, $fDeleteSubFolders = False) + If StringRight($sFolder,1) = "\" Then $sFolder = StringLeft($sFolder,StringLen($sFolder) - 1) + If _OutlookFolderExist($oOutlook, $sFolder) = 0 Then Return SetError(1, 0, 0) + Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") + Local $oNamespace = $oOutlook.GetNamespace("MAPI") + Local $sSubFolderParts = StringSplit ( $sFolder, "\") + Local $oFolder = $oNamespace.GetDefaultFolder($sSubFolderParts[1]) + Local $oFolderName + If IsObj($oFolder) = 0 Then Return SetError(1, 0, 0) + Local $sFolderName = $oFolder.Name + For $iLevel = 2 to $sSubFolderParts[0] + $sFolderName &= "\" & $sSubFolderParts[$iLevel] + If _OutlookFolderExist($oOutlook, $sFolderName) Then ContinueLoop + For $oSubFolder in $oFolder.Folders + If StringMid($sFolderName,StringInStr($sFolderName,"\",0,-1) + 1) = $oSubFolder.Name Then + If $iLevel + 1 = $sSubFolderParts[0] Then + For $iIdx = 1 to $oSubFolder.Folders.Count + $oFolderName = $oSubFolder.Folders.Item($iIdx) + If $oFolderName.Name = $sSubFolderParts[$sSubFolderParts[0]] Then + If $oFolderName.Folders.Count > 0 And $fDeleteSubFolders = False Then Return SetError(3, 0, 0) + $oSubFolder.Folders.Remove ($iIdx) + EndIf + Next + ExitLoop 2 + EndIf + $oFolder = $oSubFolder + ExitLoop + EndIf + Next + Next + If _OutlookFolderExist($oOutlook, $sFolder) = 1 Then Return SetError(2, 0, 0) + Return 1 +EndFunc +;=============================================================================== +; +; Function Name: _OutlookFindRootFolder() +; Description: Find the Mail Root folder +; Syntax.........: _OutlookFindRootFolder(ByRef $oFolder, Byref $sRootFolderName, $sFolder) +; Parameter(s): $oFolder - The Folder Object +; $sRootFolderName - The name of the Root Folder +; $sFolder - The Folder to search for +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): Return 1 if folder is found, otherwise 0 +; Author(s): Wooltown +; Created: 2009-02-26 +; Modified: 2009-03-11 - Return 1 if folder is found, otherwise 0 +; +;=============================================================================== +Func _OutlookFindRootFolder(ByRef $oFolder, Byref $sRootFolderName, $sFolder) + Local $sSubFolder = "", $iReturnValue = 0 + If StringInStr($sFolder,"\") > 0 Then + $sSubFolder = StringMid($sFolder,StringInStr($sFolder,"\") + 1) + $sFolder = StringLeft($sFolder,StringInStr($sFolder,"\") - 1) + EndIf + For $oSubFolder in $oFolder.Folders + If $sFolder = $oSubFolder.Name Then + $sRootFolderName &= "\" & $oSubFolder.Name + $oFolder = $oSubFolder + If $sSubFolder <> "" Then + $iReturnValue = _OutlookFindRootFolder($oFolder, $sRootFolderName, $sSubFolder) + Else + $iReturnValue = 1 + EndIf + Return $iReturnValue + EndIf + Next + Return $iReturnValue +EndFunc + +;=============================================================================== +; +; Function Name: _OutlookFindMailInTree() +; Description: Find all Mail in tree structure +; Syntax.........: _OutlookFindMailInTree(ByRef $asMail, $oFolder, $sFolderName, $fSubFolders, $sFrom, $sTo, $sCc, $sBCc, $sSubject, $iImportance, $fOnlyReturnUnread, $iSetStatus, $fCountMailOnly = False) +; Parameter(s): $asMail - Array with all mails +; Parameter(s): $oFolder - The Folder Object +; $sFolderName - The Folder to search for mail in +; $fSubFolders - Will Subfolders be searched ? +; $sFrom - The e-mail address of the sender +; $sTo - The recipiant(s) +; $sCc - The CC recipiant(s) of the mail +; $sBCc - The BCC recipiant(s) of the mail +; $sSubject - The Subject of the mail +; $iImportance - The Importance of the mail +; $fOnlyReturnUnread - Return all mail - False, only unread - True +; $iSetStatus - 0 - Don't change status +; 1 - Set as Read +; 2 - Set as UnRead +; 3 - Change status Read > Unread, Unread > Read +; $fCountMailOnly - False - Report all +; True - Report only number of items +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): On Success - Array in the following format: [10000][16] +; [0][0] - Total Number of items +; [0][1] - Number of unread items +; [1][0] - Sender name +; [1][1] - Sender Email address +; [1][2] - To +; [1][3] - Cc +; [1][4] - Bcc +; [1][5] - ReceivedTime +; [1][6] - SentOn +; [1][7] - Subject +; [1][8] - Folder +; [1][9] - Body +; [1][10] - BodyFormat +; [1][11] - Importance +; [1][12] - Unread +; [1][13] - Size +; [1][14] - FlagIcon +; [1][15] - Attachments +; [1][16] - Class +; [n][n] - Item n +; Author(s): Wooltown +; Created: 2009-02-26 +; Modified: 2009-03-02 +; +;=============================================================================== +Func _OutlookFindMailInTree(ByRef $asMail, $oFolder, $sFolderName, $fSubFolders, $sFrom, $sTo, $sCc, $sBCc, $sSubject, $iImportance, $fOnlyReturnUnread, $iSetStatus, $fCountMailOnly) + If $fSubFolders = True Then + For $oSubFolder in $oFolder.Folders + _OutlookFindMailInTree($asMail, $oSubFolder, $sFolderName & "\" & $oSubFolder.Name, $fSubFolders, $sFrom, $sTo, $sCc, $sBCc, $sSubject, $iImportance, $fOnlyReturnUnread, $iSetStatus, $fCountMailOnly) + Next + EndIf + Local $oFileName, $iMail = $asMail[0][0] + Local $oItems = $oFolder.Items + $asMail[0][0] += $oItems.Count + $asMail[0][1] += $oFolder.UnReadItemCount + If $asMail[0][0] >= 9999 Then + SetError (4) + Return $asMail + EndIf + If $fCountMailOnly = False Then + For $oMessage In $oFolder.Items + $iMail += 1 + $iAttachCnt = $oMessage.Attachments.Count + $asMail[$iMail][0] = $oMessage.SenderName + $asMail[$iMail][1] = $oMessage.SenderEmailAddress + $asMail[$iMail][2] = $oMessage.To + $asMail[$iMail][3] = $oMessage.Cc + $asMail[$iMail][4] = $oMessage.Bcc + $asMail[$iMail][5] = $oMessage.ReceivedTime + $asMail[$iMail][6] = $oMessage.SentOn + $asMail[$iMail][7] = $oMessage.Subject + $asMail[$iMail][8] = $sFolderName + $asMail[$iMail][9] = $oMessage.Body + $asMail[$iMail][10] = $oMessage.BodyFormat + $asMail[$iMail][11] = $oMessage.Importance + $asMail[$iMail][12] = $oMessage.UnRead + $asMail[$iMail][13] = $oMessage.Size + $asMail[$iMail][14] = $oMessage.FlagIcon + $iAttachCnt = $oMessage.Attachments.Count + If $iAttachCnt > 0 Then + For $iCtr = 1 To $iAttachCnt + If $iCtr = 1 Then + $oFileName = $oMessage.Attachments.Item($iCtr) + ;$asMail[$iMail][15] &= $oMessage.Attachments.Item($iCtr).FileName + $asMail[$iMail][15] &= $oFileName.FileName + Else + $oFileName = $oMessage.Attachments.Item($iCtr) + ;$asMail[$iMail][15] &= ";" & $oMessage.Attachments.Item($iCtr).FileName + $asMail[$iMail][15] &= ";" & $oFileName.FileName + EndIf + Next + EndIf + $asMail[$iMail][16] = $oMessage.Class + If $fOnlyReturnUnread = True Then + If $asMail[$iMail][12] = False Then + $iMail -= 1 + ContinueLoop + EndIf + EndIf + If Not ($sFrom = "" And $sTo = "" And $sCc = "" And $sBCc = "" And $sSubject = "" And $iImportance = "") Then + If $sFrom <> "" Then + If StringInStr($asMail[$iMail][0],$sFrom) = 0 Then + $iMail -= 1 + ContinueLoop + EndIf + EndIf + If $sTo <> "" Then + If StringInStr($asMail[$iMail][2],$sTo) = 0 Then + $iMail -= 1 + ContinueLoop + EndIf + EndIf + If $sCc <> "" Then + If StringInStr($asMail[$iMail][3],$sCc) = 0 Then + $iMail -= 1 + ContinueLoop + EndIf + EndIf + If $sBcc <> "" Then + If StringInStr($asMail[$iMail][4],$sBcc) = 0 Then + $iMail -= 1 + ContinueLoop + EndIf + EndIf + If $sSubject <> "" Then + If StringInStr($asMail[$iMail][7],$sSubject) = 0 Then + $iMail -= 1 + ContinueLoop + EndIf + EndIf + If $iImportance <> "" Then + If StringInStr($asMail[$iMail][11],$iImportance) = 0 Then + $iMail -= 1 + ContinueLoop + EndIf + EndIf + EndIf + Switch $iSetStatus + Case 1 + $oMessage.UnRead = False + Case 2 + $oMessage.UnRead = True + Case 3 + If $oMessage.UnRead = False Then + $oMessage.UnRead = True + Else + $oMessage.UnRead = False + EndIf + EndSwitch + Next + EndIf +EndFunc +;=============================================================================== +; +; Function Name: _OutlookError() +; Description: Called if an ObjEvent error occurs +; Requirement(s): AutoIt3 with COM support (post 3.1.1) +; Return Value(s): 9 +; Author(s): Wooltown +; Created: 2009-02-09 +; Modified: - +; +;=============================================================================== +Func _OutlookError() + Return SetError(9, 0, 0) +EndFunc \ No newline at end of file diff --git a/Leo Notes/Releases/.media b/Leo Notes/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/Leo Notes/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) + diff --git a/Leo Notes/_Zip.au3 b/Leo Notes/_Zip.au3 new file mode 100755 index 0000000..6bb9dcd --- /dev/null +++ b/Leo Notes/_Zip.au3 @@ -0,0 +1,929 @@ +#include-once + +; =============================================================================================================== +; +; Description: ZIP Functions +; Author: wraithdu +; Date: 2011-12-08 +; Credits: PsaltyDS for the original idea on which this UDF is based. +; torels for the basic framework on which this UDF is based. +; +; NOTES: +; This UDF attempts to register a COM error handler if one does not exist. This is done to prevent +; any fatal COM errors. If you have implemented your own COM error handler, this WILL NOT replace it. +; +; The Shell object does not have a delete method, so some workarounds have been implemented. The +; options are either an interactive method (as in right-click -> Delete) or a slower method (slow for +; large files). The interactive method is the main function, while the slow method is in the internal +; function section near the bottom. +; +; When adding a file item to a ZIP archive, if the file exists and the overwrite flag is set, the slower +; internal delete method is used. This is the only way to make this step non-interactive. It will be +; slow for large files. +; +; NOTE: This does not work in Windows XP, it will fail with an error. +; +; As a result, neither does adding files directly to a subdirectory. So please don't try it. As a +; workaround, create the directory structure that holds your files in a temporary location, and add the +; root directory to the root of the zip file. +; +; The zipfldr library does not allow overwriting or merging of folders in a ZIP archive. That means +; if you try to add a folder and a folder with that name already exists, it will simply fail. Period. +; As such, I've disabled that functionality. +; +; I've also removed the AddFolderContents function. There are too many pitfalls with that scenario, not +; the least of which being the above restriction. +; +; =============================================================================================================== + +;;; Start COM error Handler +;===== +; if a COM error handler does not already exist, assign one +If Not ObjEvent("AutoIt.Error") Then + ; MUST assign this to a variable + Global Const $_Zip_COMErrorHandler = ObjEvent("AutoIt.Error", "_Zip_COMErrorFunc") +EndIf + + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_AddItem +; Description....: Add a file or folder to a ZIP archive +; Syntax.........: _Zip_AddItem($sZipFile, $sItem[, $sDestDir = ""[, $iFlag = 21]]) +; Parameters.....: $sZipFile - Full path to ZIP file +; $sItem - Full path to item to add +; $sDestDir - [Optional] Destination subdirectory in which to place the item +; + Directory must be formatted similarly: "some\sub\dir" +; $iFlag - [Optional] File copy flags (Default = 1+4+16) +; | 1 - Overwrite destination file if it exists +; | 4 - No progress box +; | 8 - Rename the file if a file of the same name already exists +; | 16 - Respond "Yes to All" for any dialog that is displayed +; | 64 - Preserve undo information, if possible +; | 256 - Display a progress dialog box but do not show the file names +; | 512 - Do not confirm the creation of a new directory if the operation requires one to be created +; |1024 - Do not display a user interface if an error occurs +; |2048 - Version 4.71. Do not copy the security attributes of the file +; |4096 - Only operate in the local directory, don't operate recursively into subdirectories +; |8192 - Version 5.0. Do not copy connected files as a group, only copy the specified files +; +; Return values..: Success - 1 +; Failure - 0 and sets @error +; | 1 - zipfldr.dll does not exist +; | 2 - Library not installed +; | 3 - Destination ZIP file not a full path +; | 4 - Item to add not a full path +; | 5 - Item to add does not exist +; | 6 - Destination subdirectory cannot be a full path +; | 7 - Destination ZIP file does not exist +; | 8 - Destination item exists and is a folder (see Remarks) +; | 9 - Destination item exists and overwrite flag not set +; |10 - Destination item exists and failed to overwrite +; |11 - Failed to create internal directory structure +; +; Author.........: wraithdu +; Modified.......: +; Remarks........: Destination folders CANNOT be overwritten or merged. They must be manually deleted first. +; Related........: +; Link...........: +; Example........: +; =============================================================================================================== +Func _Zip_AddItem($sZipFile, $sItem, $sDestDir = "", $iFlag = 21) + If Not _Zip_DllChk() Then Return SetError(@error, 0, 0) + If Not _IsFullPath($sZipFile) Then Return SetError(3, 0, 0) + If Not _IsFullPath($sItem) Then Return SetError(4, 0, 0) + If Not FileExists($sItem) Then Return SetError(5, 0, 0) + If _IsFullPath($sDestDir) Then Return SetError(6, 0, 0) + ; clean paths + $sItem = _Zip_PathStripSlash($sItem) + $sDestDir = _Zip_PathStripSlash($sDestDir) + Local $sNameOnly = _Zip_PathNameOnly($sItem) + ; process overwrite flag + Local $iOverwrite = 0 + If BitAND($iFlag, 1) Then + $iOverwrite = 1 + $iFlag -= 1 + EndIf + ; check for overwrite, if target exists... + Local $sTest = $sNameOnly + If $sDestDir <> "" Then $sTest = $sDestDir & "\" & $sNameOnly + Local $itemExists = _Zip_ItemExists($sZipFile, $sTest) + If @error Then Return SetError(7, 0, 0) + If $itemExists Then + If @extended Then + ; get out, cannot overwrite folders... AT ALL + Return SetError(8, 0, 0) + Else + If $iOverwrite Then + _Zip_InternalDelete($sZipFile, $sTest) + If @error Then Return SetError(10, 0, 0) + Else + Return SetError(9, 0, 0) + EndIf + EndIf + EndIf + Local $sTempFile = "" + If $sDestDir <> "" Then + $sTempFile = _Zip_AddPath($sZipFile, $sDestDir) + If @error Then Return SetError(11, 0, 0) + EndIf + Local $oNS = _Zip_GetNameSpace($sZipFile, $sDestDir) + ; copy the item(s) + $oNS.CopyHere($sItem, $iFlag) + Do + Sleep(250) + Until IsObj($oNS.ParseName($sNameOnly)) + If $sTempFile <> "" Then + _Zip_InternalDelete($sZipFile, $sDestDir & "\" & $sTempFile) + If @error Then Return SetError(12, 0, 0) + EndIf + Return 1 +EndFunc ;==>_Zip_AddItem + +Func _Zip_COMErrorFunc() +EndFunc ;==>_Zip_COMErrorFunc + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_Count +; Description....: Count items in the root of a ZIP archive (not recursive) +; Syntax.........: _Zip_Count($sZipFile) +; Parameters.....: $sZipFile - Full path to ZIP file +; +; Return values..: Success - Item count +; Failure - 0 and sets @error +; | 1 - zipfldr.dll does not exist +; | 2 - Library not installed +; | 3 - Not a full path +; | 4 - ZIP file does not exist +; Author.........: wraithdu, torels +; Modified.......: +; Remarks........: +; Related........: +; Link...........: +; Example........: +; =============================================================================================================== +Func _Zip_Count($sZipFile) + If Not _Zip_DllChk() Then Return SetError(@error, 0, 0) + If Not _IsFullPath($sZipFile) Then Return SetError(3, 0, 0) + Local $oNS = _Zip_GetNameSpace($sZipFile) + If Not IsObj($oNS) Then Return SetError(4, 0, 0) + Return $oNS.Items().Count +EndFunc ;==>_Zip_Count + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_CountAll +; Description....: Recursively count items contained in a ZIP archive +; Syntax.........: _Zip_CountAll($sZipFile) +; Parameters.....: $sZipFile - Full path to ZIP file +; $sSub - [Internal] +; $iFileCount - [Internal] +; $iFolderCount - [Internal] +; +; Return values..: Success - Array with file and folder count +; [0] - File count +; [1] - Folder count +; Failure - 0 and sets @error +; | 1 - zipfldr.dll does not exist +; | 2 - Library not installed +; | 3 - Not a full path +; | 4 - ZIP file does not exist +; Author.........: wraithdu +; Modified.......: +; Remarks........: +; Related........: +; Link...........: +; Example........: +; =============================================================================================================== +Func _Zip_CountAll($sZipFile, $sSub = "", $iFileCount = 0, $iFolderCount = 0) + If Not _Zip_DllChk() Then Return SetError(@error, 0, 0) + If Not _IsFullPath($sZipFile) Then Return SetError(3, 0, 0) + Local $oNS = _Zip_GetNameSpace($sZipFile, $sSub) + If Not IsObj($oNS) Then Return SetError(4, 0, 0) + Local $oItems = $oNS.Items(), $aCount, $sSub2 + For $oItem In $oItems + ; reset subdir so recursion doesn't break + $sSub2 = $sSub + If $oItem.IsFolder Then + ; folder, recurse + $iFolderCount += 1 + If $sSub2 = "" Then + $sSub2 = $oItem.Name + Else + $sSub2 &= "\" & $oItem.Name + EndIf + $aCount = _Zip_CountAll($sZipFile, $sSub2, $iFileCount, $iFolderCount) + $iFileCount = $aCount[0] + $iFolderCount = $aCount[1] + Else + $iFileCount += 1 + EndIf + Next + Dim $aCount[2] = [$iFileCount, $iFolderCount] + Return $aCount +EndFunc ;==>_Zip_CountAll + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_Create +; Description....: Create empty ZIP archive +; Syntax.........: _Zip_Create($sFileName[, $iOverwrite = 0]) +; Parameters.....: $sFileName - Name of new ZIP file +; $iOverwrite - [Optional] Overwrite flag (Default = 0) +; | 0 - Do not overwrite the file if it exists +; | 1 - Overwrite the file if it exists +; +; Return values..: Success - Name of the new file +; Failure - 0 and sets @error +; | 1 - A file with that name already exists and $iOverwrite flag is not set +; | 2 - Failed to create new file +; Author.........: wraithdu, torels +; Modified.......: +; Remarks........: +; Related........: +; Link...........: +; Example........: +; =============================================================================================================== +Func _Zip_Create($sFileName, $iOverwrite = 0) + If FileExists($sFileName) And Not $iOverwrite Then Return SetError(1, 0, 0) + Local $hFp = FileOpen($sFileName, 2 + 8 + 16) + If $hFp = -1 Then Return SetError(2, 0, 0) + FileWrite($hFp, Binary("0x504B0506000000000000000000000000000000000000")) + FileClose($hFp) + Return $sFileName +EndFunc ;==>_Zip_Create + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_DeleteItem +; Description....: Delete a file or folder from a ZIP archive +; Syntax.........: _Zip_DeleteItem($sZipFile, $sFileName) +; Parameters.....: $sZipFile - Full path to the ZIP file +; $sFileName - Name of the item in the ZIP file +; +; Return values..: Success - 1 +; Failure - 0 and sets @error +; | 1 - zipfldr.dll does not exist +; | 2 - Library not installed +; | 3 - Not a full path +; | 4 - ZIP file does not exist +; | 5 - Item not found in ZIP file +; | 6 - Failed to get list of verbs +; | 7 - Failed to delete item +; Author.........: wraithdu +; Modified.......: +; Remarks........: $sFileName may be a path to an item from the root of the ZIP archive. +; For example, some ZIP file 'test.zip' has a subpath 'some\dir\file.ext'. Do not include a leading or trailing '\'. +; Related........: +; Link...........: +; Example........: +; =============================================================================================================== +Func _Zip_DeleteItem($sZipFile, $sFileName) + If Not _Zip_DllChk() Then Return SetError(@error, 0, 0) + If Not _IsFullPath($sZipFile) Then Return SetError(3, 0, 0) + ; parse filename + Local $sPath = "" + $sFileName = _Zip_PathStripSlash($sFileName) + If StringInStr($sFileName, "\") Then + ; subdirectory, parse out path and filename + $sPath = _Zip_PathPathOnly($sFileName) + $sFileName = _Zip_PathNameOnly($sFileName) + EndIf + Local $oNS = _Zip_GetNameSpace($sZipFile, $sPath) + If Not IsObj($oNS) Then Return SetError(4, 0, 0) + Local $oFolderItem = $oNS.ParseName($sFileName) + If Not IsObj($oFolderItem) Then Return SetError(5, 0, 0) + Local $oVerbs = $oFolderItem.Verbs() + If Not IsObj($oVerbs) Then Return SetError(6, 0, 0) + For $oVerb In $oVerbs + If StringReplace($oVerb.Name, "&", "") = "delete" Then + $oVerb.DoIt() + Return 1 + EndIf + Next + Return SetError(7, 0, 0) +EndFunc ;==>_Zip_DeleteItem + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_ItemExists +; Description....: Determines if an item exists in a ZIP file +; Syntax.........: _Zip_ItemExists($sZipFile, $sItem) +; Parameters.....: $sZipFile - Full path to ZIP file +; $sItem - Name of item +; +; Return values..: Success - 1 +; @extended is set to 1 if the item is a folder, 0 if a file +; Failure - 0 and sets @error +; | 1 - zipfldr.dll does not exist +; | 2 - Library not installed +; | 3 - Not a full path +; | 4 - ZIP file does not exist +; Author.........: wraithdu +; Modified.......: +; Remarks........: $sItem may be a path to an item from the root of the ZIP archive. +; For example, some ZIP file 'test.zip' has a subpath 'some\dir\file.ext'. Do not include a leading or trailing '\'. +; Related........: +; Link...........: +; Example........: +; =============================================================================================================== +Func _Zip_ItemExists($sZipFile, $sItem) + If Not _Zip_DllChk() Then Return SetError(@error, 0, 0) + If Not _IsFullPath($sZipFile) Then Return SetError(3, 0, 0) + Local $sPath = "" + $sItem = _Zip_PathStripSlash($sItem) + If StringInStr($sItem, "\") Then + ; subfolder + $sPath = _Zip_PathPathOnly($sItem) + $sItem = _Zip_PathNameOnly($sItem) + EndIf + Local $oNS = _Zip_GetNameSpace($sZipFile, $sPath) + If Not IsObj($oNS) Then Return 0 + Local $oItem = $oNS.ParseName($sItem) + ; @extended holds whether item is a file (0) or folder (1) + If IsObj($oItem) Then Return SetExtended(Number($oItem.IsFolder), 1) + Return 0 +EndFunc ;==>_Zip_ItemExists + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_List +; Description....: List items in the root of a ZIP archive (not recursive) +; Syntax.........: _Zip_List($sZipFile) +; Parameters.....: $sZipFile - Full path to ZIP file +; +; Return values..: Success - Array of items +; Failure - 0 and sets @error +; | 1 - zipfldr.dll does not exist +; | 2 - Library not installed +; | 3 - Not a full path +; | 4 - ZIP file does not exist +; Author.........: wraithdu, torels +; Modified.......: +; Remarks........: Item count is returned in array[0]. +; Related........: +; Link...........: +; Example........: +; =============================================================================================================== +Func _Zip_List($sZipFile) + If Not _Zip_DllChk() Then Return SetError(@error, 0, 0) + If Not _IsFullPath($sZipFile) Then Return SetError(3, 0, 0) + Local $oNS = _Zip_GetNameSpace($sZipFile) + If Not IsObj($oNS) Then Return SetError(4, 0, 0) + Local $aArray[1] = [0] + Local $oList = $oNS.Items() + For $oItem In $oList + $aArray[0] += 1 + ReDim $aArray[$aArray[0] + 1] + $aArray[$aArray[0]] = $oItem.Name + Next + Return $aArray +EndFunc ;==>_Zip_List + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_ListAll +; Description....: List all files inside a ZIP archive +; Syntax.........: _Zip_ListAll($sZipFile[, $iFullPath = 1]) +; Parameters.....: $sZipFile - Full path to ZIP file +; $iFullPath - [Optional] Path flag (Default = 1) +; | 0 - Return file names only +; | 1 - Return full paths of files from the archive root +; +; Return values..: Success - Array of file names / paths +; Failure - 0 and sets @error +; | 1 - zipfldr.dll does not exist +; | 2 - Library not installed +; | 3 - Not a full path +; | 4 - ZIP file or subfolder does not exist +; Author.........: wraithdu +; Modified.......: +; Remarks........: File count is returned in array[0], does not list folders. +; Related........: +; Link...........: +; Example........: +; =============================================================================================================== +Func _Zip_ListAll($sZipFile, $iFullPath = 1) + If Not _Zip_DllChk() Then Return SetError(@error, 0, 0) + If Not _IsFullPath($sZipFile) Then Return SetError(3, 0, 0) + Local $aArray[1] = [0] + _Zip_ListAll_Internal($sZipFile, "", $aArray, $iFullPath) + If @error Then + Return SetError(@error, 0, 0) + Else + Return $aArray + EndIf +EndFunc ;==>_Zip_ListAll + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_Search +; Description....: Search for files in a ZIP archive +; Syntax.........: _Zip_Search($sZipFile, $sSearchString) +; Parameters.....: $sZipFile - Full path to ZIP file +; $sSearchString - Substring to search +; +; Return values..: Success - Array of matching file paths from the root of the archive +; Failure - 0 and sets @error +; | 1 - zipfldr.dll does not exist +; | 2 - Library not installed +; | 3 - Not a full path +; | 4 - ZIP file or subfolder does not exist +; | 5 - No matching files found +; Author.........: wraithdu +; Modified.......: +; Remarks........: Found file count is returned in array[0]. +; Related........: +; Link...........: +; Example........: +; =============================================================================================================== +Func _Zip_Search($sZipFile, $sSearchString) + Local $aList = _Zip_ListAll($sZipFile) + If @error Then Return SetError(@error, 0, 0) + Local $aArray[1] = [0], $sName + For $i = 1 To $aList[0] + $sName = $aList[$i] + If StringInStr($sName, "\") Then + ; subdirectory, isolate file name + $sName = _Zip_PathNameOnly($sName) + EndIf + If StringInStr($sName, $sSearchString) Then + $aArray[0] += 1 + ReDim $aArray[$aArray[0] + 1] + $aArray[$aArray[0]] = $aList[$i] + EndIf + Next + If $aArray[0] = 0 Then + ; no files found + Return SetError(5, 0, 0) + Else + Return $aArray + EndIf +EndFunc ;==>_Zip_Search + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_SearchInFile +; Description....: Search file contents of files in a ZIP archive +; Syntax.........: _Zip_SearchInFile($sZipFile, $sSearchString) +; Parameters.....: $sZipFile - Full path to ZIP file +; $sSearchString - Substring to search +; +; Return values..: Success - Array of matching file paths from the root of the archive +; Failure - 0 and sets @error +; | 1 - zipfldr.dll does not exist +; | 2 - Library not installed +; | 3 - Not a full path +; | 4 - ZIP file or subfolder does not exist +; | 5 - Failed to create temporary directory +; | 6 - Failed to extract ZIP file to temporary directory +; | 7 - No matching files found +; Author.........: wraithdu +; Modified.......: +; Remarks........: Found file count is returned in array[0]. +; Related........: +; Link...........: +; Example........: +; =============================================================================================================== +Func _Zip_SearchInFile($sZipFile, $sSearchString) + Local $aList = _Zip_ListAll($sZipFile) + If @error Then Return SetError(@error, 0, 0) + Local $sTempDir = _Zip_CreateTempDir() + If @error Then Return SetError(5, 0, 0) + _Zip_UnzipAll($sZipFile, $sTempDir) ; flag = 20 -> no dialog, yes to all + If @error Then + DirRemove($sTempDir, 1) + Return SetError(6, 0, 0) + EndIf + Local $aArray[1] = [0], $sData + For $i = 1 To $aList[0] + $sData = FileRead($sTempDir & "\" & $aList[$i]) + If StringInStr($sData, $sSearchString) Then + $aArray[0] += 1 + ReDim $aArray[$aArray[0] + 1] + $aArray[$aArray[0]] = $aList[$i] + EndIf + Next + DirRemove($sTempDir, 1) + If $aArray[0] = 0 Then + ; no files found + Return SetError(7, 0, 0) + Else + Return $aArray + EndIf +EndFunc ;==>_Zip_SearchInFile + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_Unzip +; Description....: Extract a single item from a ZIP archive +; Syntax.........: _Zip_Unzip($sZipFile, $sFileName, $sDestPath[, $iFlag = 21]) +; Parameters.....: $sZipFile - Full path to ZIP file +; $sFileName - Name of the item in the ZIP file +; $sDestPath - Full path to the destination +; $iFlag - [Optional] File copy flags (Default = 1+4+16) +; | 1 - Overwrite destination file if it exists +; | 4 - No progress box +; | 8 - Rename the file if a file of the same name already exists +; | 16 - Respond "Yes to All" for any dialog that is displayed +; | 64 - Preserve undo information, if possible +; | 256 - Display a progress dialog box but do not show the file names +; | 512 - Do not confirm the creation of a new directory if the operation requires one to be created +; |1024 - Do not display a user interface if an error occurs +; |2048 - Version 4.71. Do not copy the security attributes of the file +; |4096 - Only operate in the local directory, don't operate recursively into subdirectories +; |8192 - Version 5.0. Do not copy connected files as a group, only copy the specified files +; +; Return values..: Success - 1 +; Failure - 0 and sets @error +; | 1 - zipfldr.dll does not exist +; | 2 - Library not installed +; | 3 - Not a full path +; | 4 - ZIP file / item path does not exist +; | 5 - Item not found in ZIP file +; | 6 - Failed to create destination (if necessary) +; | 7 - Failed to open destination +; | 8 - Failed to delete destination file / folder for overwriting +; | 9 - Destination exists and overwrite flag not set +; |10 - Failed to extract file +; Author.........: wraithdu, torels +; Modified.......: +; Remarks........: $sFileName may be a path to an item from the root of the ZIP archive. +; For example, some ZIP file 'test.zip' has a subpath 'some\dir\file.ext'. Do not include a leading or trailing '\'. +; If the overwrite flag is not set and the destination file / folder exists, overwriting is controlled +; by the remaining file copy flags ($iFlag) and/or user interaction. +; Related........: +; Link...........: +; Example........: +; =============================================================================================================== +Func _Zip_Unzip($sZipFile, $sFileName, $sDestPath, $iFlag = 21) + If Not _Zip_DllChk() Then Return SetError(@error, 0, 0) + If Not _IsFullPath($sZipFile) Or Not _IsFullPath($sDestPath) Then Return SetError(3, 0, 0) + ; get temp directory created by Windows + Local $sTempDir = _Zip_TempDirName($sZipFile) + ; parse filename + Local $sPath = "" + $sFileName = _Zip_PathStripSlash($sFileName) + If StringInStr($sFileName, "\") Then + ; subdirectory, parse out path and filename + $sPath = _Zip_PathPathOnly($sFileName) + $sFileName = _Zip_PathNameOnly($sFileName) + EndIf + Local $oNS = _Zip_GetNameSpace($sZipFile, $sPath) + If Not IsObj($oNS) Then Return SetError(4, 0, 0) + Local $oFolderItem = $oNS.ParseName($sFileName) + If Not IsObj($oFolderItem) Then Return SetError(5, 0, 0) + $sDestPath = _Zip_PathStripSlash($sDestPath) + If Not FileExists($sDestPath) Then + DirCreate($sDestPath) + If @error Then Return SetError(6, 0, 0) + EndIf + Local $oNS2 = _Zip_GetNameSpace($sDestPath) + If Not IsObj($oNS2) Then Return SetError(7, 0, 0) + ; process overwrite flag + Local $iOverwrite = 0 + If BitAND($iFlag, 1) Then + $iOverwrite = 1 + $iFlag -= 1 + EndIf + Local $sDestFullPath = $sDestPath & "\" & $sFileName + If FileExists($sDestFullPath) Then + ; destination file exists + If $iOverwrite Then + If StringInStr(FileGetAttrib($sDestFullPath), "D") Then + ; folder + If Not DirRemove($sDestFullPath, 1) Then Return SetError(8, 0, 0) + Else + If Not FileDelete($sDestFullPath) Then Return SetError(8, 0, 0) + EndIf + Else + Return SetError(9, 0, 0) + EndIf + EndIf + $oNS2.CopyHere($oFolderItem, $iFlag) + ; remove temp dir created by Windows + DirRemove($sTempDir, 1) + If FileExists($sDestFullPath) Then + ; success + Return 1 + Else + ; failure + Return SetError(10, 0, 0) + EndIf +EndFunc ;==>_Zip_Unzip + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_UnzipAll +; Description....: Extract all files contained in a ZIP archive +; Syntax.........: _Zip_UnzipAll($sZipFile, $sDestPath[, $iFlag = 20]) +; Parameters.....: $sZipFile - Full path to ZIP file +; $sDestPath - Full path to the destination +; $iFlag - [Optional] File copy flags (Default = 4+16) +; | 4 - No progress box +; | 8 - Rename the file if a file of the same name already exists +; | 16 - Respond "Yes to All" for any dialog that is displayed +; | 64 - Preserve undo information, if possible +; | 256 - Display a progress dialog box but do not show the file names +; | 512 - Do not confirm the creation of a new directory if the operation requires one to be created +; |1024 - Do not display a user interface if an error occurs +; |2048 - Version 4.71. Do not copy the security attributes of the file +; |4096 - Only operate in the local directory, don't operate recursively into subdirectories +; |8192 - Version 5.0. Do not copy connected files as a group, only copy the specified files +; +; Return values..: Success - 1 +; Failure - 0 and sets @error +; | 1 - zipfldr.dll does not exist +; | 2 - Library not installed +; | 3 - Not a full path +; | 4 - ZIP file does not exist +; | 5 - Failed to create destination (if necessary) +; | 6 - Failed to open destination +; | 7 - Failed to extract file(s) +; Author.........: wraithdu, torels +; Modified.......: +; Remarks........: Overwriting of destination files is controlled solely by the file copy flags (ie $iFlag = 1 is NOT valid). +; Related........: +; Link...........: +; Example........: +; =============================================================================================================== +Func _Zip_UnzipAll($sZipFile, $sDestPath, $iFlag = 20) + If Not _Zip_DllChk() Then Return SetError(@error, 0, 0) + If Not _IsFullPath($sZipFile) Or Not _IsFullPath($sDestPath) Then Return SetError(3, 0, 0) + ; get temp dir created by Windows + Local $sTempDir = _Zip_TempDirName($sZipFile) + Local $oNS = _Zip_GetNameSpace($sZipFile) + If Not IsObj($oNS) Then Return SetError(4, 0, 0) + $sDestPath = _Zip_PathStripSlash($sDestPath) + If Not FileExists($sDestPath) Then + DirCreate($sDestPath) + If @error Then Return SetError(5, 0, 0) + EndIf + Local $oNS2 = _Zip_GetNameSpace($sDestPath) + If Not IsObj($oNS2) Then Return SetError(6, 0, 0) + $oNS2.CopyHere($oNS.Items(), $iFlag) + ; remove temp dir created by WIndows + DirRemove($sTempDir, 1) + If FileExists($sDestPath & "\" & $oNS.Items().Item($oNS.Items().Count - 1).Name) Then + ; success... most likely + ; checks for existence of last item from source in destination + Return 1 + Else + ; failure + Return SetError(7, 0, 0) + EndIf +EndFunc ;==>_Zip_UnzipAll + +#region INTERNAL FUNCTIONS +; #FUNCTION# ==================================================================================================== +; Name...........: _IsFullPath +; Description....: Determines if a given path is a fully qualified path (well, roughly...) +; Syntax.........: _IsFullPath($sPath) +; Parameters.....: $sPath - Path to check +; +; Return values..: Success - True +; Failure - False +; Author.........: torels +; Modified.......: +; Remarks........: +; Related........: +; Link...........: +; Example........: +; =============================================================================================================== +Func _IsFullPath($sPath) + If StringInStr($sPath, ":\") Then + Return True + Else + Return False + EndIf +EndFunc ;==>_IsFullPath + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_AddPath +; Description....: INTERNAL FUNCTION +; Author.........: wraithdu +; =============================================================================================================== +Func _Zip_AddPath($sZipFile, $sPath) + If Not _Zip_DllChk() Then Return SetError(@error, 0, 0) + If Not _IsFullPath($sZipFile) Then Return SetError(3, 0, 0) + Local $oNS = _Zip_GetNameSpace($sZipFile) + If Not IsObj($oNS) Then Return SetError(4, 0, 0) + ; check and create directory structure + $sPath = _Zip_PathStripSlash($sPath) + Local $sNewPath = "", $sFileName = "" + If $sPath <> "" Then + Local $aDir = StringSplit($sPath, "\"), $oTest + For $i = 1 To $aDir[0] + ; check if item already exists + $oTest = $oNS.ParseName($aDir[$i]) + If IsObj($oTest) Then + ; check if folder + If Not $oTest.IsFolder Then Return SetError(5, 0, 0) + ; get next namespace level + $oNS = $oTest.GetFolder + Else + ; create temp dir + Local $sTempDir = _Zip_CreateTempDir() + If @error Then Return SetError(6, 0, 0) + Local $oTemp = _Zip_GetNameSpace($sTempDir) + ; create the directory structure + For $i = $i To $aDir[0] + $sNewPath &= $aDir[$i] & "\" + Next + DirCreate($sTempDir & "\" & $sNewPath) + $sFileName = _Zip_CreateTempName() + $sNewPath &= $sFileName + FileClose(FileOpen($sTempDir & "\" & $sNewPath, 2 + 8)) + $oNS.CopyHere($oTemp.Items()) + ; wait for file + Do + Sleep(250) + Until _Zip_ItemExists($sZipFile, $sNewPath) + DirRemove($sTempDir, 1) + ExitLoop + EndIf + Next + EndIf + Return $sFileName +EndFunc ;==>_Zip_AddPath + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_CreateTempDir +; Description....: INTERNAL FUNCTION +; Author.........: wraithdu +; =============================================================================================================== +Func _Zip_CreateTempDir() + Local $s_TempName + Do + $s_TempName = "" + While StringLen($s_TempName) < 7 + $s_TempName &= Chr(Random(97, 122, 1)) + WEnd + $s_TempName = @TempDir & "\~" & $s_TempName & ".tmp" + Until Not FileExists($s_TempName) + If Not DirCreate($s_TempName) Then Return SetError(1, 0, 0) + Return $s_TempName +EndFunc ;==>_Zip_CreateTempDir + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_CreateTempName +; Description....: INTERNAL FUNCTION +; Author.........: wraithdu +; =============================================================================================================== +Func _Zip_CreateTempName() + Local $GUID = DllStructCreate("dword Data1;word Data2;word Data3;byte Data4[8]") + DllCall("ole32.dll", "int", "CoCreateGuid", "ptr", DllStructGetPtr($GUID)) + Local $ret = DllCall("ole32.dll", "int", "StringFromGUID2", "ptr", DllStructGetPtr($GUID), "wstr", "", "int", 40) + If @error Then Return SetError(1, 0, "") + Return StringRegExpReplace($ret[2], "[}{-]", "") +EndFunc ;==>_Zip_CreateTempName + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_DllChk +; Description....: Checks if the zipfldr library is installed +; Syntax.........: _Zip_DllChk() +; Parameters.....: None. +; Return values..: Success - 1 +; Failure - 0 and sets @error +; | 1 - zipfldr.dll not found +; | 2 - Library not installed +; Author.........: wraithdu, torels +; Modified.......: +; Remarks........: +; Related........: +; Link...........: +; Example........: +; =============================================================================================================== +Func _Zip_DllChk() + If Not FileExists(@SystemDir & "\zipfldr.dll") Then Return SetError(1, 0, 0) + If Not RegRead("HKEY_CLASSES_ROOT\CLSID\{E88DCCE0-B7B3-11d1-A9F0-00AA0060FA31}", "") Then Return SetError(2, 0, 0) + Return 1 +EndFunc ;==>_Zip_DllChk + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_GetNameSpace +; Description....: INTERNAL FUNCTION +; Author.........: wraithdu +; =============================================================================================================== +Func _Zip_GetNameSpace($sZipFile, $sPath = "") + If Not _Zip_DllChk() Then Return SetError(@error, 0, 0) + If Not _IsFullPath($sZipFile) Then Return SetError(3, 0, 0) + Local $oApp = ObjCreate("Shell.Application") + Local $oNS = $oApp.NameSpace($sZipFile) + If Not IsObj($oNS) Then Return SetError(4, 0, 0) + If $sPath <> "" Then + ; subfolder + Local $aPath = StringSplit($sPath, "\") + Local $oItem + For $i = 1 To $aPath[0] + $oItem = $oNS.ParseName($aPath[$i]) + If Not IsObj($oItem) Then Return SetError(5, 0, 0) + $oNS = $oItem.GetFolder + If Not IsObj($oNS) Then Return SetError(6, 0, 0) + Next + EndIf + Return $oNS +EndFunc ;==>_Zip_GetNameSpace + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_InternalDelete +; Description....: INTERNAL FUNCTION +; Author.........: wraithdu +; =============================================================================================================== +Func _Zip_InternalDelete($sZipFile, $sFileName) + If Not _Zip_DllChk() Then Return SetError(@error, 0, 0) + If Not _IsFullPath($sZipFile) Then Return SetError(3, 0, 0) + ; parse filename + Local $sPath = "" + $sFileName = _Zip_PathStripSlash($sFileName) + If StringInStr($sFileName, "\") Then + ; subdirectory, parse out path and filename + $sPath = _Zip_PathPathOnly($sFileName) + $sFileName = _Zip_PathNameOnly($sFileName) + EndIf + Local $oNS = _Zip_GetNameSpace($sZipFile, $sPath) + If Not IsObj($oNS) Then Return SetError(4, 0, 0) + Local $oFolderItem = $oNS.ParseName($sFileName) + If Not IsObj($oFolderItem) Then Return SetError(5, 0, 0) + ; ## Ugh, this was ultimately a bad solution + ; move file to a temp directory and remove the directory + Local $sTempDir = _Zip_CreateTempDir() + If @error Then Return SetError(6, 0, 0) + Local $oApp = ObjCreate("Shell.Application") + $oApp.NameSpace($sTempDir).MoveHere($oFolderItem, 20) + DirRemove($sTempDir, 1) + $oFolderItem = $oNS.ParseName($sFileName) + If IsObj($oFolderItem) Then + ; failure + Return SetError(7, 0, 0) + Else + Return 1 + EndIf +EndFunc ;==>_Zip_InternalDelete + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_ListAll_Internal +; Description....: INTERNAL FUNCTION +; Author.........: wraithdu +; =============================================================================================================== +Func _Zip_ListAll_Internal($sZipFile, $sSub, ByRef $aArray, $iFullPath, $sPrefix = "") + Local $oNS = _Zip_GetNameSpace($sZipFile, $sSub) + If Not IsObj($oNS) Then Return SetError(4, 0, 0) + Local $oList = $oNS.Items(), $sSub2 + For $oItem In $oList + ; reset subdir so recursion doesn't break + $sSub2 = $sSub + If $oItem.IsFolder Then + If $sSub2 = "" Then + $sSub2 = $oItem.Name + Else + $sSub2 &= "\" & $oItem.Name + EndIf + ; folder, recurse + If $iFullPath Then + ; build path from root of zip + _Zip_ListAll_Internal($sZipFile, $sSub2, $aArray, $iFullPath, $sSub2 & "\") + If @error Then Return SetError(4) + Else + ; just filenames + _Zip_ListAll_Internal($sZipFile, $sSub2, $aArray, $iFullPath, "") + If @error Then Return SetError(4) + EndIf + Else + $aArray[0] += 1 + ReDim $aArray[$aArray[0] + 1] + $aArray[$aArray[0]] = $sPrefix & $oItem.Name + EndIf + Next +EndFunc ;==>_Zip_ListAll_Internal + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_PathNameOnly +; Description....: INTERNAL FUNCTION +; Author.........: wraithdu +; =============================================================================================================== +Func _Zip_PathNameOnly($sPath) + Return StringRegExpReplace($sPath, ".*\\", "") +EndFunc ;==>_Zip_PathNameOnly + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_PathPathOnly +; Description....: INTERNAL FUNCTION +; Author.........: wraithdu +; =============================================================================================================== +Func _Zip_PathPathOnly($sPath) + Return StringRegExpReplace($sPath, "^(.*)\\.*?$", "${1}") +EndFunc ;==>_Zip_PathPathOnly + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_PathStripSlash +; Description....: INTERNAL FUNCTION +; Author.........: wraithdu +; =============================================================================================================== +Func _Zip_PathStripSlash($sString) + Return StringRegExpReplace($sString, "(^\\+|\\+$)", "") +EndFunc ;==>_Zip_PathStripSlash + +; #FUNCTION# ==================================================================================================== +; Name...........: _Zip_TempDirName +; Description....: INTERNAL FUNCTION +; Author.........: wraithdu, trancexxx +; =============================================================================================================== +Func _Zip_TempDirName($sZipFile) + Local $i = 0, $sTemp, $sName = _Zip_PathNameOnly($sZipFile) + Do + $i += 1 + $sTemp = @TempDir & "\Temporary Directory " & $i & " for " & $sName + Until Not FileExists($sTemp) ; this folder will be created during extraction + Return $sTemp +EndFunc ;==>_Zip_TempDirName +#endregion INTERNAL FUNCTIONS diff --git a/MSI AutoInstaller/MSI AutoInstaller.au3 b/MSI AutoInstaller/MSI AutoInstaller.au3 new file mode 100755 index 0000000..aa7c211 --- /dev/null +++ b/MSI AutoInstaller/MSI AutoInstaller.au3 @@ -0,0 +1,23 @@ + +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "TyleoAboutMe.au3" + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + diff --git a/MSI AutoInstaller/MetroGUI-UDF/MetroGUI_UDF.au3 b/MSI AutoInstaller/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/MSI AutoInstaller/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/MSI AutoInstaller/MetroGUI-UDF/MetroThemes.au3 b/MSI AutoInstaller/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/MSI AutoInstaller/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/MSI AutoInstaller/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/MSI AutoInstaller/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/MSI AutoInstaller/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/MSI AutoInstaller/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/MSI AutoInstaller/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/MSI AutoInstaller/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/MSI AutoInstaller/MetroGUI-UDF/_GUIDisable.au3 b/MSI AutoInstaller/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/MSI AutoInstaller/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/MSI AutoInstaller/Releases/.media b/MSI AutoInstaller/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/MSI AutoInstaller/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) + diff --git a/MSI AutoInstaller/TyleoAboutMe.au3 b/MSI AutoInstaller/TyleoAboutMe.au3 new file mode 100755 index 0000000..75ff526 --- /dev/null +++ b/MSI AutoInstaller/TyleoAboutMe.au3 @@ -0,0 +1,10 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/ModernNotePad/AboutMe/MetroGUI-UDF/MetroGUI_UDF.au3 b/ModernNotePad/AboutMe/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/ModernNotePad/AboutMe/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/ModernNotePad/AboutMe/MetroGUI-UDF/MetroThemes.au3 b/ModernNotePad/AboutMe/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/ModernNotePad/AboutMe/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/ModernNotePad/AboutMe/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/ModernNotePad/AboutMe/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/ModernNotePad/AboutMe/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/ModernNotePad/AboutMe/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/ModernNotePad/AboutMe/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/ModernNotePad/AboutMe/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/ModernNotePad/AboutMe/MetroGUI-UDF/_GUIDisable.au3 b/ModernNotePad/AboutMe/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/ModernNotePad/AboutMe/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/ModernNotePad/AboutMe/TyleoAboutMe.au3 b/ModernNotePad/AboutMe/TyleoAboutMe.au3 new file mode 100755 index 0000000..75ff526 --- /dev/null +++ b/ModernNotePad/AboutMe/TyleoAboutMe.au3 @@ -0,0 +1,10 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/ModernNotePad/MetroGUI-UDF/MetroGUI_UDF.au3 b/ModernNotePad/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/ModernNotePad/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/ModernNotePad/MetroGUI-UDF/MetroThemes.au3 b/ModernNotePad/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/ModernNotePad/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/ModernNotePad/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/ModernNotePad/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/ModernNotePad/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/ModernNotePad/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/ModernNotePad/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/ModernNotePad/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/ModernNotePad/MetroGUI-UDF/_GUIDisable.au3 b/ModernNotePad/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/ModernNotePad/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/ModernNotePad/ModernNotePad.au3 b/ModernNotePad/ModernNotePad.au3 new file mode 100755 index 0000000..c79b4e4 --- /dev/null +++ b/ModernNotePad/ModernNotePad.au3 @@ -0,0 +1,17 @@ +#include "MetroGUI-UDF\MetroGUI_UDF.au3" + +$ProgramName = "Modern NotePad" + +GLobal $Notepad = _Metro_CreateGUI($ProgramName,700,500) + + + + + +While 1 + $nMSG = GUIGetMsg() + Switch $nMSG + Case $Notepad + + EndSwitch +WEnd \ No newline at end of file diff --git a/ModernPower/MetroGUI-UDF/MetroGUI_UDF.au3 b/ModernPower/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/ModernPower/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/ModernPower/MetroGUI-UDF/MetroThemes.au3 b/ModernPower/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/ModernPower/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/ModernPower/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/ModernPower/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/ModernPower/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/ModernPower/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/ModernPower/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/ModernPower/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/ModernPower/MetroGUI-UDF/_GUIDisable.au3 b/ModernPower/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/ModernPower/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/ModernPower/ModernPower.au3 b/ModernPower/ModernPower.au3 new file mode 100755 index 0000000..bbc5b74 --- /dev/null +++ b/ModernPower/ModernPower.au3 @@ -0,0 +1,257 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=ModernPowerLogov2.ico +#AutoIt3Wrapper_Outfile_x64=..\..\Logiciels\ModernPower.exe +#AutoIt3Wrapper_Res_Comment=Modern Power +#AutoIt3Wrapper_Res_Description=Modern Power +#AutoIt3Wrapper_Res_Fileversion=2.0.1.2 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=Modern Power v2 +#AutoIt3Wrapper_Res_ProductVersion=2.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +#include +#include +#include "TyleoAboutMe.au3" +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include +#Region ### START Koda GUI section ### Form= + +$GeneralSound = "C:\Windows\Media\Windows Balloon.wav" + +PlayIt() + + +$AlphaDefault = "210" + +$AlphaINI = @AppDataDir & "\ModernPower_Alpha.ini" + +If FileExists($AlphaINI) Then + ; Nothing +Else + IniWrite($AlphaINI,"Alpha for Modern Power","ALPHA",$AlphaDefault) +EndIf + +$AlphaActive = IniRead($AlphaINI,"Alpha for Modern Power","ALPHA",$AlphaDefault) +$LightMode = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme") + + +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) + $theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) + $theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +$LightTh = "LightGray" +$DarkTh = "DarkRuby" + +if $LightMode = "1" Then + $ThemeActive = $LightTh +Else + $ThemeActive = $DarkTh +EndIf + +_SetTheme($ThemeActive) + +$ButtonBKColor = $CurrentAccent + +$CurrentVer = FileGetVersion(@AutoItExe) +$State = " STABLE THAURUS" + +$Soft = "Modern Power " & $CurrentVer & $State + +; DEFAULT EN_US +$lang_REBOOT = "REBOOT" +$lang_POWER = "POWER DOWN" +$lang_LOCK = "LOCK" +$lang_LOGOUT = "DISCONNECT" +$lang_RELOADEXP = "RELOAD EXPLORER" +$lang_CONFIRM = "Confirm the selected action by clicking Yes." +$lang_REXP_DONE = "Explorer Restarted !" +$lang_NOTSUPPORTED = "Your computer does'nt support reboot to UEFI / BIOS" +$lang_STANDBY = "STAND BY" + +; FRENCH MOD +if FileExists(@ScriptDir & "\fr") Then + $lang_REBOOT = "REDEMARRER" + $lang_POWER = "ARRETER" + $lang_LOCK = "VERR" + $lang_LOGOUT = "DECONNECTER" + $lang_RELOADEXP = "RECHARGER EXPLORER" + $lang_STANDBY = "MISE EN VEILLE" + $lang_CONFIRM = "Confirmez l'action séléctionnée en cliquant sur Yes." + $lang_REXP_DONE = "Explorateur Redémarré !" + $lang_NOTSUPPORTED = "Votre ordinateur ne supporte pas le redémarrage vers l'UEFI / BIOS" +EndIf + + +Global $PowerMenu = _Metro_CreateGUI($Soft,867,65,-1,15) + +$Lock = _Metro_CreateButtonEx2($lang_LOCK,12,13,60,48,$CurrentAccent,0xFFFFFF,"Segoe UI",11,1,0x000000) +$PowerDown = _Metro_CreateButtonEx2($lang_POWER,73,13,150,48,$CurrentAccent,0xFFFFFF,"Segoe UI",11,1,0x000000) +$Reboot = _Metro_CreateButtonEx2($lang_REBOOT,224,13,150,48,$CurrentAccent,0xFFFFFF,"Segoe UI",11,1,0x000000) +$Logout = _Metro_CreateButtonEx2($lang_LOGOUT,375,13,150,48,$CurrentAccent,0xFFFFFF,"Segoe UI",11,1,0x000000) +$StandBy = _Metro_CreateButtonEx2($lang_STANDBY,526,13,150,48,$CurrentAccent,0xFFFFFF,"Segoe UI",11,1,0x000000) +$ReloadExp = _Metro_CreateButtonEx2($lang_RELOADEXP,677,13,150,48,$CurrentAccent,0xFFFFFF,"Segoe UI",11,1,0x000000) +$Close = _Metro_CreateButtonEx2("❌",845,4 + 10,17,17,$CurrentAccent,0xFF5151,"Segoe UI",7.5) +$UnDim = _Metro_CreateButtonEx2("/",845,19 + 10,17,17,$CurrentAccent,0xFFFFFF,"Segoe UI",7.5) +$About = _Metro_CreateButtonEx2("?",845,34 + 10,17,17,$CurrentAccent,0xFFFFFF,"Segoe UI",7.5) +$Force = _Metro_CreateButtonEx2("F",828,4 + 10,17,17,$CurrentAccent,0xFFFFFF,"Segoe UI",7.5) +$Dim = _Metro_CreateButtonEx2("\",828,19 + 10,17,17,$CurrentAccent,0xFFFFFF,"Segoe UI",7.5) +$Firmware = _Metro_CreateButtonEx2("W",828,34 + 10,17,17,$CurrentAccent,0xFFFFFF,"Segoe UI",7.5) +GUICtrlSetTip($Firmware,"Firmware") +GUICtrlSetTip($Dim,"Dim") +GUICtrlSetTip($UnDim,"UnDim") +GUICtrlSetTip($Force,"Force Shutdown") +GUICtrlSetTip($Close,"Close") +GUICtrlSetTip($About,"About") + +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +$hGUI=GUICreate("",@DesktopWidth,@DesktopHeight,0,0,0x80000000,0x08000080) +WinSetTrans($hGUI, "", $AlphaActive) +GUISetBkColor($CurrentAccent) +WinSetState($hGUI, "", @SW_SHOW) +WinSetOnTop($PowerMenu, "", 1) + +HotKeySet("{ESCAPE}","Echap") + +Local $MsgBox_Form + +_Gui_RoundCorners($PowerMenu,11,11,11,11) + +While 1 + $nMsg = GUIGetMsg() + WinSetOnTop($PowerMenu, "", 1) + Switch $nMsg + Case $UnDim + PlayIt() + HideIt() + + Case $Dim + PlayIt() + UnHideIt() + + Case $StandBy + Shutdown($SD_STANDBY) + Exit(0) + + Case $Firmware + PlayIt() + $Confirm = _Metro_MsgBox(4,"FIRMWARE",$lang_CONFIRM & @CRLF & "REBOOT TO UEFI FIRMWARE (MUST BE POSSIBLE)",370) + PlayIt() + If $Confirm = "Yes" Then + Run("shutdown /fw /r","",@SW_HIDE) + Sleep(250) + _Metro_MsgBox(0,"NO UEFI / UEFI VERSION NOT SUPPORTED",$lang_NOTSUPPORTED) + PlayIt() + Endif + + Case $PowerDown + PlayIt() + $Confirm = _Metro_MsgBox(4,$lang_POWER,$lang_CONFIRM,370) + PlayIt() + If $Confirm = "Yes" Then + Run("shutdown -p","",@SW_HIDE) + Exit(0) + Endif + + Case $Force + PlayIt() + $Confirm = _Metro_MsgBox(4,"EMERGENCY MODE",$lang_CONFIRM & @CRLF & "EMERGENCY MODE - FORCE SHUTDOWN",370) + PlayIt() + If $Confirm = "Yes" Then + Run("taskkill /im explorer.exe /f","",@SW_HIDE) + Run("taskkill /im chrome.exe /f","",@SW_HIDE) + Run("taskkill /im msedge.exe /f","",@SW_HIDE) + Run("taskkill /im firefox.exe /f","",@SW_HIDE) + Run("taskkill /im opera.exe /f","",@SW_HIDE) + Run("taskkill /im maxthon.exe /f","",@SW_HIDE) + Run("shutdown -p -f","",@SW_HIDE) + Exit(0) + Endif + + Case $Reboot + PlayIt() + $Confirm = _Metro_MsgBox(4,$lang_REBOOT,$lang_CONFIRM,370) + PlayIt() + If $Confirm = "Yes" Then + Run("shutdown -r -t 00","",@SW_HIDE) + Exit(0) + Endif + + Case $Lock + PlayIt() + Sleep(220) + Run("Rundll32.exe user32.dll,LockWorkStation","",@SW_HIDE) + Exit(0) + + Case $Logout + PlayIt() + $Confirm = _Metro_MsgBox(4,$lang_LOGOUT,$lang_CONFIRM,370) + PlayIt() + If $Confirm = "Yes" Then + Run("shutdown -l","",@SW_HIDE) + Exit(0) + Endif + + Case $ReloadExp + PlayIt() + Run("taskkill /im explorer.exe /f","",@SW_HIDE) + Sleep(1200) + ShellExecute("explorer") + Sleep(1000) + PlayIt() + _Metro_MsgBox(0,"",$lang_REXP_DONE,200) + WinSetOnTop($hGUI, "", 1) + WinSetOnTop($PowerMenu, "", 1) + + Case $Close + PlayIt() + Sleep(220) + Exit(0) + + Case $About + PlayIt() + TyleoAbout($Soft) + PlayIt() + + EndSwitch +WEnd + +Func ForceTop() + WinSetOnTop($hGUI, "", 1) + WinSetOnTop($PowerMenu, "", 1) +EndFunc + +Func HideIt() + WinSetState($hGUI,"",@SW_HIDE) +EndFunc + +Func UnHideIt() + WinSetState($hGUI,"",@SW_SHOW) +EndFunc + +Func Echap() + GUIDelete($hGUI) + Exit(0) +EndFunc + +Func PlayIt() + if FileExists($GeneralSound) Then + SoundPlay($GeneralSound,0) + EndIf +EndFunc + +Func _Gui_RoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3) + Local $XS_pos, $XS_ret, $XS_ret2 + $XS_pos = WinGetPos($h_win) + $XS_ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", _ + $i_y1, "long", $XS_pos[2], "long", $XS_pos[3], "long", $i_x3, "long", $i_y3) + If $XS_ret[0] Then + $XS_ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", _ + $XS_ret[0], "int", 1) + EndIf +EndFunc \ No newline at end of file diff --git a/ModernPower/ModernPower.exe b/ModernPower/ModernPower.exe new file mode 100755 index 0000000..8f83f1c Binary files /dev/null and b/ModernPower/ModernPower.exe differ diff --git a/ModernPower/ModernPower.ico b/ModernPower/ModernPower.ico new file mode 100755 index 0000000..fe5373a Binary files /dev/null and b/ModernPower/ModernPower.ico differ diff --git a/ModernPower/ModernPowerLogov2.ico b/ModernPower/ModernPowerLogov2.ico new file mode 100755 index 0000000..a372cf0 Binary files /dev/null and b/ModernPower/ModernPowerLogov2.ico differ diff --git a/ModernPower/Releases/ModernPower.exe b/ModernPower/Releases/ModernPower.exe new file mode 100755 index 0000000..f69ed55 Binary files /dev/null and b/ModernPower/Releases/ModernPower.exe differ diff --git a/ModernPower/Releases/Setup.exe b/ModernPower/Releases/Setup.exe new file mode 100755 index 0000000..a07f65b Binary files /dev/null and b/ModernPower/Releases/Setup.exe differ diff --git a/ModernPower/Setup.au3 b/ModernPower/Setup.au3 new file mode 100755 index 0000000..c0136a9 --- /dev/null +++ b/ModernPower/Setup.au3 @@ -0,0 +1,40 @@ +#RequireAdmin +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=ModernPowerLogov2.ico +#AutoIt3Wrapper_Outfile_x64=..\..\Logiciels\Setup.exe +#AutoIt3Wrapper_Res_Comment=Modern Power +#AutoIt3Wrapper_Res_Description=Modern Power +#AutoIt3Wrapper_Res_Fileversion=2.0.0.26 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=Modern Power v2 +#AutoIt3Wrapper_Res_ProductVersion=2.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +#include +#include +#include "TyleoAboutMe.au3" +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +$InstallVer = FileGetVersion(@ScriptDir & "\ModernPower.exe") +$InstallDir = @ProgramFilesDir & "\ModernPower" +$InstalledBin = $InstallDir & "\ModernPower.exe" + +If FileExists(@ScriptDir & "\ModernPower.exe") Then + $Confirm = _Metro_MsgBox(4,"MODERN POWER SETUP","Click Yes to Install Modern Power." & @CRLF & "Setup will use the existing version in the same folder of the setup executable." & @CRLF & " " & @CRLF & "Version : " & $InstallVer) + If $Confirm = "Yes" Then + DirCreate($InstallDir) + FileDelete($InstallDir & "\ModernPower.exe") + FileCopy(@ScriptDir & "\ModernPower.exe",$InstallDir) + FileCreateShortcut($InstallDir & "\ModernPower.exe", @DesktopCommonDir & "\Modern Power") + FileCreateShortcut($InstallDir & "\ModernPower.exe", @StartMenuCommonDir & "\Modern Power") + $fr_Confirm = _Metro_MsgBox(4,"FRENCH PATCH","Do you want to install French Lang Patch ?" & @CRLF & "Voulez-vous installer le patch Français ?") + if $fr_Confirm = "Yes" Then + FileWrite($InstallDir & "\fr","FrenchPatch") + EndIf + EndIf +Else + _Metro_MsgBox(0+16,"ERROR","No Ressource 'ModernPower.exe' found. Exiting.") +EndIf \ No newline at end of file diff --git a/ModernPower/TyleoAboutMe.au3 b/ModernPower/TyleoAboutMe.au3 new file mode 100755 index 0000000..75ff526 --- /dev/null +++ b/ModernPower/TyleoAboutMe.au3 @@ -0,0 +1,10 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/ModernPower/fr b/ModernPower/fr new file mode 100755 index 0000000..e69de29 diff --git a/ModernPower/readme.md b/ModernPower/readme.md new file mode 100755 index 0000000..0502ebc --- /dev/null +++ b/ModernPower/readme.md @@ -0,0 +1,3 @@ +Comment activer la langue française ? + +Créer un fichier vide sans extension "fr" a coté de l'executable de Modern Power. \ No newline at end of file diff --git a/MyNotePad/MetroGUI-UDF/MetroGUI_UDF.au3 b/MyNotePad/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/MyNotePad/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/MyNotePad/MetroGUI-UDF/MetroThemes.au3 b/MyNotePad/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/MyNotePad/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/MyNotePad/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/MyNotePad/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/MyNotePad/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/MyNotePad/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/MyNotePad/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/MyNotePad/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/MyNotePad/MetroGUI-UDF/_GUIDisable.au3 b/MyNotePad/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/MyNotePad/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/MyNotePad/Modern NotePad.au3 b/MyNotePad/Modern NotePad.au3 new file mode 100755 index 0000000..9f34a9c --- /dev/null +++ b/MyNotePad/Modern NotePad.au3 @@ -0,0 +1,54 @@ +#include +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "TyleoAboutMe.au3" +#include "WindowsLCA.au3" + +$CurrentVer = FileGetVersion(@AutoItExe) +$Progname = "Modern Note " & $CurrentVer + +Global $Note = GUICreate("Modern Note", 264, 189, 234, 184) +GUISetBkColor($CurrentAccent) + + +Global $File = GUICtrlCreateMenu("File") +Global $File_Open = GUICtrlCreateMenuItem("Open Note" & @TAB & "NTT",$File) +Global $File_Save = GUICtrlCreateMenuItem("Save Note" & @TAB & "NTT",$File) +Global $File_Save_As = GUICtrlCreateMenuItem("Save Note As..." & @TAB & "NTT",$File) + +Global $File_Export = GUICtrlCreateMenu("Export",$File) +Global $File_Export_TXT = GUICtrlCreateMenuItem("Text File" & @TAB & "TXT",$File_Export) +Global $File_Export_PDF = GUICtrlCreateMenuItem("PDF File" & @TAB & "PDF",$File_Export) + + +Global $Edition = GUICtrlCreateMenu("Edition") +Global $Edition_SelectAll = GUICtrlCreateMenuItem("Select All",$Edition) + + +Global $Configuration = GUICtrlCreateMenu("Configuration") +Global $Configuration_Font = GUICtrlCreateMenuItem("Change Font",$Configuration) + + +Global $About = GUICtrlCreateMenu("About") +Global $About_About = GUICtrlCreateMenuItem("About Me",$About) +Global $About_Ver = GUICtrlCreateMenuItem($CurrentVer,$About) + +GUICtrlSetState($About_Ver,$GUI_DISABLE) +Global $NoteEditor = GUICtrlCreateEdit("", 4, 4, 255, 160, BitOR($ES_WANTRETURN, $WS_VSCROLL)) +GUICtrlSetData(-1, "") +GUISetState(@SW_SHOW) + +$ButtonBKColor = $CurrentAccent + + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + Case $About_About + TyleoAbout($Progname) + + EndSwitch +WEnd diff --git a/MyNotePad/TyleoAboutMe.au3 b/MyNotePad/TyleoAboutMe.au3 new file mode 100755 index 0000000..75ff526 --- /dev/null +++ b/MyNotePad/TyleoAboutMe.au3 @@ -0,0 +1,10 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/MyNotePad/WindowsLCA.au3 b/MyNotePad/WindowsLCA.au3 new file mode 100755 index 0000000..6bc0577 --- /dev/null +++ b/MyNotePad/WindowsLCA.au3 @@ -0,0 +1,7 @@ + + +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor \ No newline at end of file diff --git a/NAG Leo/Extensions.au3 b/NAG Leo/Extensions.au3 new file mode 100755 index 0000000..4c3ee19 --- /dev/null +++ b/NAG Leo/Extensions.au3 @@ -0,0 +1,34 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +; Color Accent +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +; Software Base Details +Func GetSoftDetails($Exe,$Stage) + Global $CurrentVersion,$CurrentName,$CurrentBaseVersion + $CurrentVersion = FileGetVersion($Exe,$FV_FILEVERSION) + $CurrentBaseVersion = FileGetVersion($Exe,$FV_PRODUCTVERSION) + $CurrentName = FileGetVersion($Exe,$FV_PRODUCTNAME) + if $Stage = "BETA" Then + $CurrentVersion = $CurrentVersion & "-beta" + Elseif $Stage = "RELEASE" or $Stage = "STABLE" Then + $CurrentVersion = $CurrentVersion & "-rel" + Else + $CurrentVersion = $CurrentVersion & "-dev" + EndIf + Return True +EndFunc + +; About Us +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/NAG Leo/Form1.kxf b/NAG Leo/Form1.kxf new file mode 100755 index 0000000..73fdd3c --- /dev/null +++ b/NAG Leo/Form1.kxf @@ -0,0 +1,829 @@ + + + + 191 + 145 + 1166 + 695 + Form1 + clBtnFace + DEFAULT_CHARSET + clWindowText + -11 + MS Sans Serif + + False + True + -1798701056 + 256 + 1.04 + False + False + False + False + -1 + 1 + 0 + 1 + + 96 + 13 + + + + + 8 + 16 + 129 + 25 + Button1 + 0 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 40 + 129 + 25 + Button1 + 1 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 64 + 129 + 25 + Button1 + 2 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 88 + 129 + 25 + Button1 + 3 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 112 + 129 + 25 + Button1 + 4 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 136 + 129 + 25 + Button1 + 5 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 160 + 129 + 25 + Button1 + 6 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 184 + 129 + 25 + Button1 + 7 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 208 + 129 + 25 + Button1 + 8 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 232 + 129 + 25 + Button1 + 9 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 256 + 129 + 25 + Button1 + 10 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 280 + 129 + 25 + Button1 + 11 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 304 + 129 + 25 + Button1 + 12 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 328 + 129 + 25 + Button1 + 13 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 352 + 129 + 25 + Button1 + 14 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 376 + 129 + 25 + Button1 + 15 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 400 + 129 + 25 + Button1 + 16 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 424 + 129 + 25 + Button1 + 17 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 448 + 129 + 25 + Button1 + 18 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 472 + 129 + 25 + Button1 + 19 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 496 + 129 + 25 + Button1 + 20 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 520 + 129 + 25 + Button1 + 21 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 544 + 129 + 25 + Button1 + 22 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 568 + 129 + 25 + Button1 + 23 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 592 + 129 + 25 + Button1 + 24 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 8 + 616 + 129 + 25 + Button1 + 25 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 16 + 129 + 25 + Button1 + 26 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 40 + 129 + 25 + Button1 + 27 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 64 + 129 + 25 + Button1 + 28 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 88 + 129 + 25 + Button1 + 29 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 112 + 129 + 25 + Button1 + 30 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 136 + 129 + 25 + Button1 + 31 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 160 + 129 + 25 + Button1 + 32 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 184 + 129 + 25 + Button1 + 33 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 208 + 129 + 25 + Button1 + 34 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 232 + 129 + 25 + Button1 + 35 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 256 + 129 + 25 + Button1 + 36 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 280 + 129 + 25 + Button1 + 37 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 304 + 129 + 25 + Button1 + 38 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 328 + 129 + 25 + Button1 + 39 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 352 + 129 + 25 + Button1 + 40 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 376 + 129 + 25 + Button1 + 41 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 400 + 129 + 25 + Button1 + 42 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 424 + 129 + 25 + Button1 + 43 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 448 + 129 + 25 + Button1 + 44 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 472 + 129 + 25 + Button1 + 45 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 496 + 129 + 25 + Button1 + 46 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 520 + 129 + 25 + Button1 + 47 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 544 + 129 + 25 + Button1 + 48 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 568 + 129 + 25 + Button1 + 49 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 592 + 129 + 25 + Button1 + 50 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 584 + 616 + 129 + 25 + Button1 + 51 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 560 + -8 + 17 + 665 + Button53 + 52 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + \ No newline at end of file diff --git a/NAG Leo/Form1.kxf.bak b/NAG Leo/Form1.kxf.bak new file mode 100755 index 0000000..9a19b69 --- /dev/null +++ b/NAG Leo/Form1.kxf.bak @@ -0,0 +1,49 @@ + + + + 190 + 157 + 1166 + 695 + Form1 + clBtnFace + DEFAULT_CHARSET + clWindowText + -11 + MS Sans Serif + + False + True + -1798701056 + 256 + 1.04 + False + False + False + False + -1 + 1 + 0 + 1 + + 96 + 13 + + + + + 8 + 8 + 129 + 33 + Button1 + 0 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + \ No newline at end of file diff --git a/NAG Leo/Hosts.ini b/NAG Leo/Hosts.ini new file mode 100755 index 0000000..2d0405a --- /dev/null +++ b/NAG Leo/Hosts.ini @@ -0,0 +1,52 @@ +[Hosts NagLeo] +Host-1=intra +Host-2=localhost +Host-3=localhost +Host-4=localhost +Host-5=localhost +Host-6=localhost +Host-7=localhost +Host-8=localhost +Host-9=localhost +Host-10=localhost +Host-11=localhost +Host-12=localhost +Host-13=localhost +Host-14=localhost +Host-15=localhost +Host-16=localhost +Host-17=localhost +Host-18=localhost +Host-19=localhost +Host-20=localhost +Host-21=localhost +Host-22=localhost +Host-23=localhost +Host-24=localhost +Host-25=localhost +Host-26=localhost +Host-27=localhost +Host-28=localhost +Host-29=localhost +Host-30=localhost +Host-31=localhost +Host-32=localhost +Host-33=localhost +Host-34=localhost +Host-35=localhost +Host-36=localhost +Host-37=localhost +Host-38=localhost +Host-39=localhost +Host-40=localhost +Host-41=localhost +Host-42=localhost +Host-43=localhost +Host-44=localhost +Host-45=localhost +Host-46=localhost +Host-47=localhost +Host-48=localhost +Host-49=localhost +Host-50=localhost +Host-51=localhost diff --git a/NAG Leo/MetroGUI-UDF/MetroGUI_UDF.au3 b/NAG Leo/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/NAG Leo/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/NAG Leo/MetroGUI-UDF/MetroThemes.au3 b/NAG Leo/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/NAG Leo/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/NAG Leo/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/NAG Leo/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/NAG Leo/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/NAG Leo/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/NAG Leo/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/NAG Leo/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/NAG Leo/MetroGUI-UDF/_GUIDisable.au3 b/NAG Leo/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/NAG Leo/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/NAG Leo/NAG Leo - Control.au3 b/NAG Leo/NAG Leo - Control.au3 new file mode 100755 index 0000000..64ffa68 --- /dev/null +++ b/NAG Leo/NAG Leo - Control.au3 @@ -0,0 +1,48 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=SupervisionNAGLeo_stop.ico +#AutoIt3Wrapper_Outfile_x64=..\..\Logiciels\NAGLeo\NAG_Stop.Exe +#AutoIt3Wrapper_Res_Comment=NAGLeo - Stop +#AutoIt3Wrapper_Res_Description=NAGLeo - Stop +#AutoIt3Wrapper_Res_Fileversion=1.0.0.4 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=NAGLeo - Stop +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + +GetSoftDetails(@AutoItExe,"DEV") + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +#Region ### START Koda GUI section ### Form= +Global $Form2 = GUICreate("", 169, 47, 302, 218) +GUISetBkColor($CurrentAccent,$Form2) +Global $Button1 = GUICtrlCreateButton("STOP", 8, 8, 153, 33) +GUICtrlSetFont(-1, 20, 400, 0, "Segoe UI") +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +While ProcessExists("NAG.exe") + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + ProcessClose("NAG.exe") + Exit + Case $Button1 + ProcessClose("NAG.exe") + + EndSwitch +WEnd diff --git a/NAG Leo/NAG Leo.au3 b/NAG Leo/NAG Leo.au3 new file mode 100755 index 0000000..f964013 --- /dev/null +++ b/NAG Leo/NAG Leo.au3 @@ -0,0 +1,1625 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=SupervisionNAGLeo.ico +#AutoIt3Wrapper_Outfile_x64=..\..\Logiciels\NAGLeo\NAG.exe +#AutoIt3Wrapper_Res_Comment=NAGLeo - Supervision Embarquée Portable +#AutoIt3Wrapper_Res_Description=NAGLeo - Supervision Embarquée Portable +#AutoIt3Wrapper_Res_Fileversion=1.0.0.27 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=NAGLeo +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +#include +#include +#include +#Region ### START Koda GUI section ### Form=H:\Supervision\Form1.kxf + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + +GetSoftDetails(@AutoItExe,"STABLE") + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +if FileExists(@ScriptDir & "\NAG_Stop.exe") Then + Run("NAG_Stop.exe") +Else + MsgBox(0+16,"Error","This software is incomplete. Recheck your Download source.") + Exit(1) +Endif +Global $Supervision = GUICreate("Supervision NAG-Leo", 1148, 657, 191, 145) +GUISetBkColor($CurrentAccent,$Supervision) +GUISetFont(9, 900,"", "Arial", $Supervision) + +$defaulthost = "disabled" +$defaulttimeout = "2000" +$config = @ScriptDir & "\Hosts.ini" +$timeout = @ScriptDir & "\Timeout.ini" + +If FileExists($timeout) Then + ; Already Configured +Else + IniWrite($timeout,"Config TimeOut NagLeo","TimeOut(ms)",$defaulttimeout) +Endif + +$tm = IniRead($timeout,"Config TimeOut NagLeo","TimeOut(ms)",$defaulttimeout) + +if FileExists($config) Then + ; Already Configured +Else + IniWrite($config,"Hosts NagLeo","Host-1",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-2",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-3",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-4",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-5",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-6",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-7",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-8",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-9",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-10",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-11",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-12",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-13",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-14",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-15",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-16",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-17",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-18",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-19",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-20",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-21",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-22",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-23",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-24",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-25",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-26",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-27",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-28",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-29",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-30",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-31",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-32",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-33",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-34",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-35",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-36",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-37",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-38",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-39",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-40",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-41",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-42",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-43",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-44",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-45",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-46",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-47",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-48",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-49",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-50",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-51",$defaulthost) +Endif + +; First init +$c1 = IniRead($config,"Hosts NagLeo","Host-1",$defaulthost) +$c2 = IniRead($config,"Hosts NagLeo","Host-2",$defaulthost) +$c3 = IniRead($config,"Hosts NagLeo","Host-3",$defaulthost) +$c4 = IniRead($config,"Hosts NagLeo","Host-4",$defaulthost) +$c5 = IniRead($config,"Hosts NagLeo","Host-5",$defaulthost) +$c6 = IniRead($config,"Hosts NagLeo","Host-6",$defaulthost) +$c7 = IniRead($config,"Hosts NagLeo","Host-7",$defaulthost) +$c8 = IniRead($config,"Hosts NagLeo","Host-8",$defaulthost) +$c9 = IniRead($config,"Hosts NagLeo","Host-9",$defaulthost) +$c10 = IniRead($config,"Hosts NagLeo","Host-10",$defaulthost) +$c11 = IniRead($config,"Hosts NagLeo","Host-11",$defaulthost) +$c12 = IniRead($config,"Hosts NagLeo","Host-12",$defaulthost) +$c13 = IniRead($config,"Hosts NagLeo","Host-13",$defaulthost) +$c14 = IniRead($config,"Hosts NagLeo","Host-14",$defaulthost) +$c15 = IniRead($config,"Hosts NagLeo","Host-15",$defaulthost) +$c16 = IniRead($config,"Hosts NagLeo","Host-16",$defaulthost) +$c17 = IniRead($config,"Hosts NagLeo","Host-17",$defaulthost) +$c18 = IniRead($config,"Hosts NagLeo","Host-18",$defaulthost) +$c19 = IniRead($config,"Hosts NagLeo","Host-19",$defaulthost) +$c20 = IniRead($config,"Hosts NagLeo","Host-20",$defaulthost) +$c21 = IniRead($config,"Hosts NagLeo","Host-21",$defaulthost) +$c22 = IniRead($config,"Hosts NagLeo","Host-22",$defaulthost) +$c23 = IniRead($config,"Hosts NagLeo","Host-23",$defaulthost) +$c24 = IniRead($config,"Hosts NagLeo","Host-24",$defaulthost) +$c25 = IniRead($config,"Hosts NagLeo","Host-25",$defaulthost) +$c26 = IniRead($config,"Hosts NagLeo","Host-26",$defaulthost) +$c27 = IniRead($config,"Hosts NagLeo","Host-27",$defaulthost) +$c28 = IniRead($config,"Hosts NagLeo","Host-28",$defaulthost) +$c29 = IniRead($config,"Hosts NagLeo","Host-29",$defaulthost) +$c30 = IniRead($config,"Hosts NagLeo","Host-30",$defaulthost) +$c31 = IniRead($config,"Hosts NagLeo","Host-31",$defaulthost) +$c32 = IniRead($config,"Hosts NagLeo","Host-32",$defaulthost) +$c33 = IniRead($config,"Hosts NagLeo","Host-33",$defaulthost) +$c34 = IniRead($config,"Hosts NagLeo","Host-34",$defaulthost) +$c35 = IniRead($config,"Hosts NagLeo","Host-35",$defaulthost) +$c36 = IniRead($config,"Hosts NagLeo","Host-36",$defaulthost) +$c37 = IniRead($config,"Hosts NagLeo","Host-37",$defaulthost) +$c38 = IniRead($config,"Hosts NagLeo","Host-38",$defaulthost) +$c39 = IniRead($config,"Hosts NagLeo","Host-39",$defaulthost) +$c40 = IniRead($config,"Hosts NagLeo","Host-40",$defaulthost) +$c41 = IniRead($config,"Hosts NagLeo","Host-41",$defaulthost) +$c42 = IniRead($config,"Hosts NagLeo","Host-42",$defaulthost) +$c43 = IniRead($config,"Hosts NagLeo","Host-43",$defaulthost) +$c44 = IniRead($config,"Hosts NagLeo","Host-44",$defaulthost) +$c45 = IniRead($config,"Hosts NagLeo","Host-45",$defaulthost) +$c46 = IniRead($config,"Hosts NagLeo","Host-46",$defaulthost) +$c47 = IniRead($config,"Hosts NagLeo","Host-47",$defaulthost) +$c48 = IniRead($config,"Hosts NagLeo","Host-48",$defaulthost) +$c49 = IniRead($config,"Hosts NagLeo","Host-49",$defaulthost) +$c50 = IniRead($config,"Hosts NagLeo","Host-50",$defaulthost) +$c51 = IniRead($config,"Hosts NagLeo","Host-51",$defaulthost) + +; Menu +Global $Rclick_Files = GUICtrlCreateContextMenu() +Global $Rclick_Ver = GUICtrlCreateMenuItem("Version & Devs",$Rclick_Files) + +; Zone 1 +; States +Global $State1 = GUICtrlCreateButton("N/A", 8, 16, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State2 = GUICtrlCreateButton("N/A", 8, 40, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State3 = GUICtrlCreateButton("N/A", 8, 64, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State4 = GUICtrlCreateButton("N/A", 8, 88, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State5 = GUICtrlCreateButton("N/A", 8, 112, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State6 = GUICtrlCreateButton("N/A", 8, 136, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State7 = GUICtrlCreateButton("N/A", 8, 160, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State8 = GUICtrlCreateButton("N/A", 8, 184, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State9 = GUICtrlCreateButton("N/A", 8, 208, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State10 = GUICtrlCreateButton("N/A", 8, 232, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State11 = GUICtrlCreateButton("N/A", 8, 256, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State12 = GUICtrlCreateButton("N/A", 8, 280, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State13 = GUICtrlCreateButton("N/A", 8, 304, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State14 = GUICtrlCreateButton("N/A", 8, 328, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State15 = GUICtrlCreateButton("N/A", 8, 352, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State16 = GUICtrlCreateButton("N/A", 8, 376, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State17 = GUICtrlCreateButton("N/A", 8, 400, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State18 = GUICtrlCreateButton("N/A", 8, 424, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State19 = GUICtrlCreateButton("N/A", 8, 448, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State20 = GUICtrlCreateButton("N/A", 8, 472, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State21 = GUICtrlCreateButton("N/A", 8, 496, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State22 = GUICtrlCreateButton("N/A", 8, 520, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State23 = GUICtrlCreateButton("N/A", 8, 544, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State24 = GUICtrlCreateButton("N/A", 8, 568, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State25 = GUICtrlCreateButton("N/A", 8, 592, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State26 = GUICtrlCreateButton("N/A", 8, 616, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) + +; Names +Global $Name1 = GUICtrlCreateLabel(" " & $c1, 137, 16, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name2 = GUICtrlCreateLabel(" " & $c2, 137, 40, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name3 = GUICtrlCreateLabel(" " & $c3, 137, 64, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name4 = GUICtrlCreateLabel(" " & $c4, 137, 88, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name5 = GUICtrlCreateLabel(" " & $c5, 137, 112, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name6 = GUICtrlCreateLabel(" " & $c6, 137, 136, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name7 = GUICtrlCreateLabel(" " & $c7, 137, 160, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name8 = GUICtrlCreateLabel(" " & $c8, 137, 184, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name9 = GUICtrlCreateLabel(" " & $c9, 137, 208, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name10 = GUICtrlCreateLabel(" " & $c10, 137, 232, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name11 = GUICtrlCreateLabel(" " & $c11, 137, 256, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name12 = GUICtrlCreateLabel(" " & $c12, 137, 280, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name13 = GUICtrlCreateLabel(" " & $c13, 137, 304, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name14 = GUICtrlCreateLabel(" " & $c14, 137, 328, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name15 = GUICtrlCreateLabel(" " & $c15, 137, 352, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name16 = GUICtrlCreateLabel(" " & $c16, 137, 376, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name17 = GUICtrlCreateLabel(" " & $c17, 137, 400, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name18 = GUICtrlCreateLabel(" " & $c18, 137, 424, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name19 = GUICtrlCreateLabel(" " & $c19, 137, 448, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name20 = GUICtrlCreateLabel(" " & $c20, 137, 472, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name21 = GUICtrlCreateLabel(" " & $c21, 137, 496, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name22 = GUICtrlCreateLabel(" " & $c22, 137, 520, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name23 = GUICtrlCreateLabel(" " & $c23, 137, 544, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name24 = GUICtrlCreateLabel(" " & $c24, 137, 568, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name25 = GUICtrlCreateLabel(" " & $c25, 137, 592, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name26 = GUICtrlCreateLabel(" " & $c26, 137, 616, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) + +; Zone 2 +; States +Global $State27 = GUICtrlCreateButton("N/A", 584, 16, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State28 = GUICtrlCreateButton("N/A", 584, 40, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State29 = GUICtrlCreateButton("N/A", 584, 64, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State30 = GUICtrlCreateButton("N/A", 584, 88, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State31 = GUICtrlCreateButton("N/A", 584, 112, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State32 = GUICtrlCreateButton("N/A", 584, 136, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State33 = GUICtrlCreateButton("N/A", 584, 160, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State34 = GUICtrlCreateButton("N/A", 584, 184, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State35 = GUICtrlCreateButton("N/A", 584, 208, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State36 = GUICtrlCreateButton("N/A", 584, 232, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State37 = GUICtrlCreateButton("N/A", 584, 256, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State38 = GUICtrlCreateButton("N/A", 584, 280, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State39 = GUICtrlCreateButton("N/A", 584, 304, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State40 = GUICtrlCreateButton("N/A", 584, 328, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State41 = GUICtrlCreateButton("N/A", 584, 352, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State42 = GUICtrlCreateButton("N/A", 584, 376, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State43 = GUICtrlCreateButton("N/A", 584, 400, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State44 = GUICtrlCreateButton("N/A", 584, 424, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State45 = GUICtrlCreateButton("N/A", 584, 448, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State46 = GUICtrlCreateButton("N/A", 584, 472, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State47 = GUICtrlCreateButton("N/A", 584, 496, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State48 = GUICtrlCreateButton("N/A", 584, 520, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State49 = GUICtrlCreateButton("N/A", 584, 544, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State50 = GUICtrlCreateButton("N/A", 584, 568, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $State51 = GUICtrlCreateButton("N/A", 584, 592, 129, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) + +; Names +Global $Name27 = GUICtrlCreateLabel(" " & $c27, 713, 16, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name28 = GUICtrlCreateLabel(" " & $c28, 713, 40, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name29 = GUICtrlCreateLabel(" " & $c29, 713, 64, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name30 = GUICtrlCreateLabel(" " & $c30, 713, 88, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name31 = GUICtrlCreateLabel(" " & $c31, 713, 112, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name32 = GUICtrlCreateLabel(" " & $c32, 713, 136, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name33 = GUICtrlCreateLabel(" " & $c33, 713, 160, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name34 = GUICtrlCreateLabel(" " & $c34, 713, 184, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name35 = GUICtrlCreateLabel(" " & $c35, 713, 208, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name36 = GUICtrlCreateLabel(" " & $c36, 713, 232, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name37 = GUICtrlCreateLabel(" " & $c37, 713, 256, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name38 = GUICtrlCreateLabel(" " & $c38, 713, 280, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name39 = GUICtrlCreateLabel(" " & $c39, 713, 304, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name40 = GUICtrlCreateLabel(" " & $c40, 713, 328, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name41 = GUICtrlCreateLabel(" " & $c41, 713, 352, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name42 = GUICtrlCreateLabel(" " & $c42, 713, 376, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name43 = GUICtrlCreateLabel(" " & $c43, 713, 400, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name44 = GUICtrlCreateLabel(" " & $c44, 713, 424, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name45 = GUICtrlCreateLabel(" " & $c45, 713, 448, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name46 = GUICtrlCreateLabel(" " & $c46, 713, 472, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name47 = GUICtrlCreateLabel(" " & $c47, 713, 496, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name48 = GUICtrlCreateLabel(" " & $c48, 713, 520, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name49 = GUICtrlCreateLabel(" " & $c49, 713, 544, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name50 = GUICtrlCreateLabel(" " & $c50, 713, 568, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $Name51 = GUICtrlCreateLabel(" " & $c51, 713, 592, 426, 25) +GUICtrlSetFont(-1, 12) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +Global $StartSupervision = GUICtrlCreateButton("START SUPERVISION", 584, 616, 555, 25) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetColor(-1,0xFFFFFF) +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +if $c1 = "disabled" Then + GUICtrlSetData($State1,"DISABLED") + GUICtrlSetState($State1, $GUI_DISABLE) + GUICtrlSetBkColor($State1, $CurrentAccent) +EndIf + +if $c2 = "disabled" Then + GUICtrlSetData($State2,"DISABLED") + GUICtrlSetState($State2, $GUI_DISABLE) + GUICtrlSetBkColor($State2, $CurrentAccent) +EndIf + +if $c3 = "disabled" Then + GUICtrlSetData($State3,"DISABLED") + GUICtrlSetState($State3, $GUI_DISABLE) + GUICtrlSetBkColor($State3, $CurrentAccent) +EndIf + +if $c4 = "disabled" Then + GUICtrlSetData($State4,"DISABLED") + GUICtrlSetState($State4, $GUI_DISABLE) + GUICtrlSetBkColor($State4, $CurrentAccent) +EndIf + +if $c5 = "disabled" Then + GUICtrlSetData($State5,"DISABLED") + GUICtrlSetState($State5, $GUI_DISABLE) + GUICtrlSetBkColor($State5, $CurrentAccent) +EndIf + +if $c6 = "disabled" Then + GUICtrlSetData($State6,"DISABLED") + GUICtrlSetState($State6, $GUI_DISABLE) + GUICtrlSetBkColor($State6, $CurrentAccent) +EndIf + +if $c7 = "disabled" Then + GUICtrlSetData($State7,"DISABLED") + GUICtrlSetState($State7, $GUI_DISABLE) + GUICtrlSetBkColor($State7, $CurrentAccent) +EndIf + +if $c8 = "disabled" Then + GUICtrlSetData($State8,"DISABLED") + GUICtrlSetState($State8, $GUI_DISABLE) + GUICtrlSetBkColor($State8, $CurrentAccent) +EndIf + +if $c9 = "disabled" Then + GUICtrlSetData($State9,"DISABLED") + GUICtrlSetState($State9, $GUI_DISABLE) + GUICtrlSetBkColor($State9, $CurrentAccent) +EndIf + +if $c10 = "disabled" Then + GUICtrlSetData($State10,"DISABLED") + GUICtrlSetState($State10, $GUI_DISABLE) + GUICtrlSetBkColor($State10, $CurrentAccent) +EndIf + +if $c11 = "disabled" Then + GUICtrlSetData($State11,"DISABLED") + GUICtrlSetState($State11, $GUI_DISABLE) + GUICtrlSetBkColor($State11, $CurrentAccent) +EndIf + +if $c12 = "disabled" Then + GUICtrlSetData($State12,"DISABLED") + GUICtrlSetState($State12, $GUI_DISABLE) + GUICtrlSetBkColor($State12, $CurrentAccent) +EndIf + +if $c13 = "disabled" Then + GUICtrlSetData($State13,"DISABLED") + GUICtrlSetState($State13, $GUI_DISABLE) + GUICtrlSetBkColor($State13, $CurrentAccent) +EndIf + +if $c14 = "disabled" Then + GUICtrlSetData($State14,"DISABLED") + GUICtrlSetState($State14, $GUI_DISABLE) + GUICtrlSetBkColor($State14, $CurrentAccent) +EndIf + +if $c15 = "disabled" Then + GUICtrlSetData($State15,"DISABLED") + GUICtrlSetState($State15, $GUI_DISABLE) + GUICtrlSetBkColor($State15, $CurrentAccent) +EndIf + +if $c16 = "disabled" Then + GUICtrlSetData($State16,"DISABLED") + GUICtrlSetState($State16, $GUI_DISABLE) + GUICtrlSetBkColor($State16, $CurrentAccent) +EndIf + +if $c17 = "disabled" Then + GUICtrlSetData($State17,"DISABLED") + GUICtrlSetState($State17, $GUI_DISABLE) + GUICtrlSetBkColor($State17, $CurrentAccent) +EndIf + +if $c18 = "disabled" Then + GUICtrlSetData($State18,"DISABLED") + GUICtrlSetState($State18, $GUI_DISABLE) + GUICtrlSetBkColor($State18, $CurrentAccent) +EndIf + +if $c19 = "disabled" Then + GUICtrlSetData($State19,"DISABLED") + GUICtrlSetState($State19, $GUI_DISABLE) + GUICtrlSetBkColor($State19, $CurrentAccent) +EndIf + +if $c20 = "disabled" Then + GUICtrlSetData($State20,"DISABLED") + GUICtrlSetState($State20, $GUI_DISABLE) + GUICtrlSetBkColor($State20, $CurrentAccent) +EndIf +if $c21 = "disabled" Then + GUICtrlSetData($State21,"DISABLED") + GUICtrlSetState($State21, $GUI_DISABLE) + GUICtrlSetBkColor($State21, $CurrentAccent) +EndIf + +if $c22 = "disabled" Then + GUICtrlSetData($State22,"DISABLED") + GUICtrlSetState($State22, $GUI_DISABLE) + GUICtrlSetBkColor($State22, $CurrentAccent) +EndIf + +if $c23 = "disabled" Then + GUICtrlSetData($State23,"DISABLED") + GUICtrlSetState($State23, $GUI_DISABLE) + GUICtrlSetBkColor($State23, $CurrentAccent) +EndIf + +if $c24 = "disabled" Then + GUICtrlSetData($State24,"DISABLED") + GUICtrlSetState($State24, $GUI_DISABLE) + GUICtrlSetBkColor($State24, $CurrentAccent) +EndIf + +if $c25 = "disabled" Then + GUICtrlSetData($State25,"DISABLED") + GUICtrlSetState($State25, $GUI_DISABLE) + GUICtrlSetBkColor($State25, $CurrentAccent) +EndIf + +if $c26 = "disabled" Then + GUICtrlSetData($State26,"DISABLED") + GUICtrlSetState($State26, $GUI_DISABLE) + GUICtrlSetBkColor($State26, $CurrentAccent) +EndIf + +if $c27 = "disabled" Then + GUICtrlSetData($State27,"DISABLED") + GUICtrlSetState($State27, $GUI_DISABLE) + GUICtrlSetBkColor($State27, $CurrentAccent) +EndIf + +if $c28 = "disabled" Then + GUICtrlSetData($State28,"DISABLED") + GUICtrlSetState($State28, $GUI_DISABLE) + GUICtrlSetBkColor($State28, $CurrentAccent) +EndIf + +if $c29 = "disabled" Then + GUICtrlSetData($State29,"DISABLED") + GUICtrlSetState($State29, $GUI_DISABLE) + GUICtrlSetBkColor($State29, $CurrentAccent) +EndIf + +if $c30 = "disabled" Then + GUICtrlSetData($State30,"DISABLED") + GUICtrlSetState($State30, $GUI_DISABLE) + GUICtrlSetBkColor($State30, $CurrentAccent) +EndIf +if $c31 = "disabled" Then + GUICtrlSetData($State31,"DISABLED") + GUICtrlSetState($State31, $GUI_DISABLE) + GUICtrlSetBkColor($State31, $CurrentAccent) +EndIf + +if $c32 = "disabled" Then + GUICtrlSetData($State32,"DISABLED") + GUICtrlSetState($State32, $GUI_DISABLE) + GUICtrlSetBkColor($State32, $CurrentAccent) +EndIf + +if $c33 = "disabled" Then + GUICtrlSetData($State33,"DISABLED") + GUICtrlSetState($State33, $GUI_DISABLE) + GUICtrlSetBkColor($State33, $CurrentAccent) +EndIf + +if $c34 = "disabled" Then + GUICtrlSetData($State34,"DISABLED") + GUICtrlSetState($State34, $GUI_DISABLE) + GUICtrlSetBkColor($State34, $CurrentAccent) +EndIf + +if $c35 = "disabled" Then + GUICtrlSetData($State35,"DISABLED") + GUICtrlSetState($State35, $GUI_DISABLE) + GUICtrlSetBkColor($State35, $CurrentAccent) +EndIf + +if $c36 = "disabled" Then + GUICtrlSetData($State36,"DISABLED") + GUICtrlSetState($State36, $GUI_DISABLE) + GUICtrlSetBkColor($State36, $CurrentAccent) +EndIf + +if $c37 = "disabled" Then + GUICtrlSetData($State37,"DISABLED") + GUICtrlSetState($State37, $GUI_DISABLE) + GUICtrlSetBkColor($State37, $CurrentAccent) +EndIf + +if $c38 = "disabled" Then + GUICtrlSetData($State38,"DISABLED") + GUICtrlSetState($State38, $GUI_DISABLE) + GUICtrlSetBkColor($State38, $CurrentAccent) +EndIf + +if $c39 = "disabled" Then + GUICtrlSetData($State39,"DISABLED") + GUICtrlSetState($State39, $GUI_DISABLE) + GUICtrlSetBkColor($State39, $CurrentAccent) +EndIf + +if $c40 = "disabled" Then + GUICtrlSetData($State40,"DISABLED") + GUICtrlSetState($State40, $GUI_DISABLE) + GUICtrlSetBkColor($State40, $CurrentAccent) +EndIf +if $c41 = "disabled" Then + GUICtrlSetData($State41,"DISABLED") + GUICtrlSetState($State41, $GUI_DISABLE) + GUICtrlSetBkColor($State41, $CurrentAccent) +EndIf + +if $c42 = "disabled" Then + GUICtrlSetData($State42,"DISABLED") + GUICtrlSetState($State42, $GUI_DISABLE) + GUICtrlSetBkColor($State42, $CurrentAccent) +EndIf + +if $c43 = "disabled" Then + GUICtrlSetData($State43,"DISABLED") + GUICtrlSetState($State43, $GUI_DISABLE) + GUICtrlSetBkColor($State43, $CurrentAccent) +EndIf + +if $c44 = "disabled" Then + GUICtrlSetData($State44,"DISABLED") + GUICtrlSetState($State44, $GUI_DISABLE) + GUICtrlSetBkColor($State44, $CurrentAccent) +EndIf + +if $c45 = "disabled" Then + GUICtrlSetData($State45,"DISABLED") + GUICtrlSetState($State45, $GUI_DISABLE) + GUICtrlSetBkColor($State45, $CurrentAccent) +EndIf + +if $c46 = "disabled" Then + GUICtrlSetData($State46,"DISABLED") + GUICtrlSetState($State46, $GUI_DISABLE) + GUICtrlSetBkColor($State46, $CurrentAccent) +EndIf + +if $c47 = "disabled" Then + GUICtrlSetData($State47,"DISABLED") + GUICtrlSetState($State47, $GUI_DISABLE) + GUICtrlSetBkColor($State47, $CurrentAccent) +EndIf + +if $c48 = "disabled" Then + GUICtrlSetData($State48,"DISABLED") + GUICtrlSetState($State48, $GUI_DISABLE) + GUICtrlSetBkColor($State48, $CurrentAccent) +EndIf + +if $c49 = "disabled" Then + GUICtrlSetData($State49,"DISABLED") + GUICtrlSetState($State49, $GUI_DISABLE) + GUICtrlSetBkColor($State49, $CurrentAccent) +EndIf + +if $c50 = "disabled" Then + GUICtrlSetData($State50,"DISABLED") + GUICtrlSetState($State50, $GUI_DISABLE) + GUICtrlSetBkColor($State50, $CurrentAccent) +EndIf + +if $c51 = "disabled" Then + GUICtrlSetData($State51,"DISABLED") + GUICtrlSetState($State51, $GUI_DISABLE) + GUICtrlSetBkColor($State51, $CurrentAccent) +EndIf + +$CurrentVer = FileGetVersion(@AutoItExe) + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + + Case $Rclick_Ver + TyleoAbout("NAGLeo Portable Supervisor " & $CurrentVer) + + Case $StartSupervision + While 1 + if $c1 = "disabled" Then + ; Disabled + Else + $s1 = Ping($c1,$tm) + Sleep(1250) + if $s1 = "0" or $s1 = "1" or $s1 = "2" or $s1 = "3" or $s1 = "4" Then + GUICtrlSetBkColor($State1,0xFF0000) + GUICtrlSetColor($State1,$CurrentAccent) + GUICtrlSetData($State1,"OFFLINE") + Else + GUICtrlSetBkColor($State1,0x04B404) + GUICtrlSetColor($State1,$CurrentAccent) + GUICtrlSetData($State1,"ONLINE") + Endif + Endif + if $c2 = "disabled" Then + ; Disabled + Else + $s2 = Ping($c2,$tm) + Sleep(250) + if $s2 = "0" or $s2 = "1" or $s2 = "2" or $s2 = "3" or $s2 = "4" Then + GUICtrlSetBkColor($State2,0xFF0000) + GUICtrlSetColor($State2,$CurrentAccent) + GUICtrlSetData($State2,"OFFLINE") + Else + GUICtrlSetBkColor($State2,0x04B404) + GUICtrlSetColor($State2,$CurrentAccent) + GUICtrlSetData($State2,"ONLINE") + Endif + Endif + if $c3 = "disabled" Then + ; Disabled + Else + $s3 = Ping($c3,$tm) + Sleep(250) + if $s3 = "0" or $s3 = "1" or $s3 = "2" or $s3 = "3" or $s3 = "4" Then + GUICtrlSetBkColor($State3,0xFF0000) + GUICtrlSetColor($State3,$CurrentAccent) + GUICtrlSetData($State3,"OFFLINE") + Else + GUICtrlSetBkColor($State3,0x04B404) + GUICtrlSetColor($State3,$CurrentAccent) + GUICtrlSetData($State3,"ONLINE") + Endif + Endif + if $c4 = "disabled" Then + ; Disabled + Else + $s4 = Ping($c4,$tm) + Sleep(250) + if $s4 = "0" or $s4 = "1" or $s4 = "2" or $s4 = "3" or $s4 = "4" Then + GUICtrlSetBkColor($State4,0xFF0000) + GUICtrlSetColor($State4,$CurrentAccent) + GUICtrlSetData($State4,"OFFLINE") + Else + GUICtrlSetBkColor($State4,0x04B404) + GUICtrlSetColor($State4,$CurrentAccent) + GUICtrlSetData($State4,"ONLINE") + Endif + Endif + if $c5 = "disabled" Then + ; Disabled + Else + $s5 = Ping($c5,$tm) + Sleep(250) + if $s5 = "0" or $s5 = "1" or $s5 = "2" or $s5 = "3" or $s5 = "4" Then + GUICtrlSetBkColor($State5,0xFF0000) + GUICtrlSetColor($State5,$CurrentAccent) + GUICtrlSetData($State5,"OFFLINE") + Else + GUICtrlSetBkColor($State5,0x04B404) + GUICtrlSetColor($State5,$CurrentAccent) + GUICtrlSetData($State5,"ONLINE") + Endif + Endif + if $c6 = "disabled" Then + ; Disabled + Else + $s6 = Ping($c6,$tm) + Sleep(250) + if $s6 = "0" or $s6 = "1" or $s6 = "2" or $s6 = "3" or $s6 = "4" Then + GUICtrlSetBkColor($State6,0xFF0000) + GUICtrlSetColor($State6,$CurrentAccent) + GUICtrlSetData($State6,"OFFLINE") + Else + GUICtrlSetBkColor($State6,0x04B404) + GUICtrlSetColor($State6,$CurrentAccent) + GUICtrlSetData($State6,"ONLINE") + Endif + Endif + if $c7 = "disabled" Then + ; Disabled + Else + $s7 = Ping($c7,$tm) + Sleep(250) + if $s7 = "0" or $s7 = "1" or $s7 = "2" or $s7 = "3" or $s7 = "4" Then + GUICtrlSetBkColor($State7,0xFF0000) + GUICtrlSetColor($State7,$CurrentAccent) + GUICtrlSetData($State7,"OFFLINE") + Else + GUICtrlSetBkColor($State7,0x04B404) + GUICtrlSetColor($State7,$CurrentAccent) + GUICtrlSetData($State7,"ONLINE") + Endif + Endif + if $c8 = "disabled" Then + ; Disabled + Else + $s8 = Ping($c8,$tm) + Sleep(250) + if $s8 = "0" or $s8 = "1" or $s8 = "2" or $s8 = "3" or $s8 = "4" Then + GUICtrlSetBkColor($State8,0xFF0000) + GUICtrlSetColor($State8,$CurrentAccent) + GUICtrlSetData($State8,"OFFLINE") + Else + GUICtrlSetBkColor($State8,0x04B404) + GUICtrlSetColor($State8,$CurrentAccent) + GUICtrlSetData($State8,"ONLINE") + Endif + Endif + if $c9 = "disabled" Then + ; Disabled + Else + $s9 = Ping($c9,$tm) + Sleep(250) + if $s9 = "0" or $s9 = "1" or $s9 = "2" or $s9 = "3" or $s9 = "4" Then + GUICtrlSetBkColor($State9,0xFF0000) + GUICtrlSetColor($State9,$CurrentAccent) + GUICtrlSetData($State9,"OFFLINE") + Else + GUICtrlSetBkColor($State9,0x04B404) + GUICtrlSetColor($State9,$CurrentAccent) + GUICtrlSetData($State9,"ONLINE") + Endif + Endif + if $c10 = "disabled" Then + ; Disabled + Else + $s10 = Ping($c10,$tm) + Sleep(250) + if $s10 = "0" or $s10 = "1" or $s10 = "2" or $s10 = "3" or $s10 = "4" Then + GUICtrlSetBkColor($State10,0xFF0000) + GUICtrlSetColor($State10,$CurrentAccent) + GUICtrlSetData($State10,"OFFLINE") + Else + GUICtrlSetBkColor($State10,0x04B404) + GUICtrlSetColor($State10,$CurrentAccent) + GUICtrlSetData($State10,"ONLINE") + Endif + Endif + if $c11 = "disabled" Then + ; Disabled + Else + $s11 = Ping($c1,$tm) + Sleep(250) + if $s11 = "0" or $s11 = "1" or $s11 = "2" or $s11 = "3" or $s11 = "4" Then + GUICtrlSetBkColor($State11,0xFF0000) + GUICtrlSetColor($State11,$CurrentAccent) + GUICtrlSetData($State11,"OFFLINE") + Else + GUICtrlSetBkColor($State11,0x04B404) + GUICtrlSetColor($State11,$CurrentAccent) + GUICtrlSetData($State11,"ONLINE") + Endif + Endif + if $c12 = "disabled" Then + ; Disabled + Else + $s12 = Ping($c1,$tm) + Sleep(250) + if $s12 = "0" or $s12 = "1" or $s12 = "2" or $s12 = "3" or $s12 = "4" Then + GUICtrlSetBkColor($State12,0xFF0000) + GUICtrlSetColor($State12,$CurrentAccent) + GUICtrlSetData($State12,"OFFLINE") + Else + GUICtrlSetBkColor($State12,0x04B404) + GUICtrlSetColor($State12,$CurrentAccent) + GUICtrlSetData($State12,"ONLINE") + Endif + Endif + if $c13 = "disabled" Then + ; Disabled + Else + $s13 = Ping($c1,$tm) + Sleep(250) + if $s13 = "0" or $s13 = "1" or $s13 = "2" or $s13 = "3" or $s13 = "4" Then + GUICtrlSetBkColor($State13,0xFF0000) + GUICtrlSetColor($State13,$CurrentAccent) + GUICtrlSetData($State13,"OFFLINE") + Else + GUICtrlSetBkColor($State13,0x04B404) + GUICtrlSetColor($State13,$CurrentAccent) + GUICtrlSetData($State13,"ONLINE") + Endif + Endif + if $c14 = "disabled" Then + ; Disabled + Else + $s14 = Ping($c1,$tm) + Sleep(250) + if $s14 = "0" or $s14 = "1" or $s14 = "2" or $s14 = "3" or $s14 = "4" Then + GUICtrlSetBkColor($State14,0xFF0000) + GUICtrlSetColor($State14,$CurrentAccent) + GUICtrlSetData($State14,"OFFLINE") + Else + GUICtrlSetBkColor($State14,0x04B404) + GUICtrlSetColor($State14,$CurrentAccent) + GUICtrlSetData($State14,"ONLINE") + Endif + Endif + if $c15 = "disabled" Then + ; Disabled + Else + $s15 = Ping($c1,$tm) + Sleep(250) + if $s15 = "0" or $s15 = "1" or $s15 = "2" or $s15 = "3" or $s15 = "4" Then + GUICtrlSetBkColor($State15,0xFF0000) + GUICtrlSetColor($State15,$CurrentAccent) + GUICtrlSetData($State15,"OFFLINE") + Else + GUICtrlSetBkColor($State15,0x04B404) + GUICtrlSetColor($State15,$CurrentAccent) + GUICtrlSetData($State15,"ONLINE") + Endif + Endif + if $c16 = "disabled" Then + ; Disabled + Else + $s16 = Ping($c1,$tm) + Sleep(250) + if $s16 = "0" or $s16 = "1" or $s16 = "2" or $s16 = "3" or $s16 = "4" Then + GUICtrlSetBkColor($State16,0xFF0000) + GUICtrlSetColor($State16,$CurrentAccent) + GUICtrlSetData($State16,"OFFLINE") + Else + GUICtrlSetBkColor($State16,0x04B404) + GUICtrlSetColor($State16,$CurrentAccent) + GUICtrlSetData($State16,"ONLINE") + Endif + Endif + if $c17 = "disabled" Then + ; Disabled + Else + $s17 = Ping($c1,$tm) + Sleep(250) + if $s17 = "0" or $s17 = "1" or $s17 = "2" or $s17 = "3" or $s17 = "4" Then + GUICtrlSetBkColor($State17,0xFF0000) + GUICtrlSetColor($State17,$CurrentAccent) + GUICtrlSetData($State17,"OFFLINE") + Else + GUICtrlSetBkColor($State17,0x04B404) + GUICtrlSetColor($State17,$CurrentAccent) + GUICtrlSetData($State17,"ONLINE") + Endif + Endif + if $c18 = "disabled" Then + ; Disabled + Else + $s18 = Ping($c1,$tm) + Sleep(250) + if $s18 = "0" or $s18 = "1" or $s18 = "2" or $s18 = "3" or $s18 = "4" Then + GUICtrlSetBkColor($State18,0xFF0000) + GUICtrlSetColor($State18,$CurrentAccent) + GUICtrlSetData($State18,"OFFLINE") + Else + GUICtrlSetBkColor($State18,0x04B404) + GUICtrlSetColor($State18,$CurrentAccent) + GUICtrlSetData($State18,"ONLINE") + Endif + Endif + if $c19 = "disabled" Then + ; Disabled + Else + $s19 = Ping($c1,$tm) + Sleep(250) + if $s19 = "0" or $s19 = "1" or $s19 = "2" or $s19 = "3" or $s19 = "4" Then + GUICtrlSetBkColor($State19,0xFF0000) + GUICtrlSetColor($State19,$CurrentAccent) + GUICtrlSetData($State19,"OFFLINE") + Else + GUICtrlSetBkColor($State19,0x04B404) + GUICtrlSetColor($State19,$CurrentAccent) + GUICtrlSetData($State19,"ONLINE") + Endif + Endif + if $c20 = "disabled" Then + ; Disabled + Else + $s20 = Ping($c1,$tm) + Sleep(250) + if $s20 = "0" or $s20 = "1" or $s20 = "2" or $s20 = "3" or $s20 = "4" Then + GUICtrlSetBkColor($State20,0xFF0000) + GUICtrlSetColor($State20,$CurrentAccent) + GUICtrlSetData($State20,"OFFLINE") + Else + GUICtrlSetBkColor($State20,0x04B404) + GUICtrlSetColor($State20,$CurrentAccent) + GUICtrlSetData($State20,"ONLINE") + Endif + Endif + if $c21 = "disabled" Then + ; Disabled + Else + $s21 = Ping($c1,$tm) + Sleep(250) + if $s21 = "0" or $s21 = "1" or $s21 = "2" or $s21 = "3" or $s21 = "4" Then + GUICtrlSetBkColor($State21,0xFF0000) + GUICtrlSetColor($State21,$CurrentAccent) + GUICtrlSetData($State21,"OFFLINE") + Else + GUICtrlSetBkColor($State21,0x04B404) + GUICtrlSetColor($State21,$CurrentAccent) + GUICtrlSetData($State21,"ONLINE") + Endif + Endif + if $c22 = "disabled" Then + ; Disabled + Else + $s22 = Ping($c1,$tm) + Sleep(250) + if $s22 = "0" or $s22 = "1" or $s22 = "2" or $s22 = "3" or $s22 = "4" Then + GUICtrlSetBkColor($State22,0xFF0000) + GUICtrlSetColor($State22,$CurrentAccent) + GUICtrlSetData($State22,"OFFLINE") + Else + GUICtrlSetBkColor($State22,0x04B404) + GUICtrlSetColor($State22,$CurrentAccent) + GUICtrlSetData($State22,"ONLINE") + Endif + Endif + if $c23 = "disabled" Then + ; Disabled + Else + $s23 = Ping($c1,$tm) + Sleep(250) + if $s23 = "0" or $s23 = "1" or $s23 = "2" or $s23 = "3" or $s23 = "4" Then + GUICtrlSetBkColor($State23,0xFF0000) + GUICtrlSetColor($State23,$CurrentAccent) + GUICtrlSetData($State23,"OFFLINE") + Else + GUICtrlSetBkColor($State23,0x04B404) + GUICtrlSetColor($State23,$CurrentAccent) + GUICtrlSetData($State23,"ONLINE") + Endif + Endif + if $c24 = "disabled" Then + ; Disabled + Else + $s24 = Ping($c1,$tm) + Sleep(250) + if $s24 = "0" or $s24 = "1" or $s24 = "2" or $s24 = "3" or $s24 = "4" Then + GUICtrlSetBkColor($State24,0xFF0000) + GUICtrlSetColor($State24,$CurrentAccent) + GUICtrlSetData($State24,"OFFLINE") + Else + GUICtrlSetBkColor($State24,0x04B404) + GUICtrlSetColor($State24,$CurrentAccent) + GUICtrlSetData($State24,"ONLINE") + Endif + Endif + if $c25 = "disabled" Then + ; Disabled + Else + $s25 = Ping($c1,$tm) + Sleep(250) + if $s25 = "0" or $s25 = "1" or $s25 = "2" or $s25 = "3" or $s25 = "4" Then + GUICtrlSetBkColor($State25,0xFF0000) + GUICtrlSetColor($State25,$CurrentAccent) + GUICtrlSetData($State25,"OFFLINE") + Else + GUICtrlSetBkColor($State25,0x04B404) + GUICtrlSetColor($State25,$CurrentAccent) + GUICtrlSetData($State25,"ONLINE") + Endif + Endif + if $c26 = "disabled" Then + ; Disabled + Else + $s26 = Ping($c1,$tm) + Sleep(250) + if $s26 = "0" or $s26 = "1" or $s26 = "2" or $s26 = "3" or $s26 = "4" Then + GUICtrlSetBkColor($State26,0xFF0000) + GUICtrlSetColor($State26,$CurrentAccent) + GUICtrlSetData($State26,"OFFLINE") + Else + GUICtrlSetBkColor($State26,0x04B404) + GUICtrlSetColor($State26,$CurrentAccent) + GUICtrlSetData($State26,"ONLINE") + Endif + Endif + if $c27 = "disabled" Then + ; Disabled + Else + $s27 = Ping($c1,$tm) + Sleep(250) + if $s27 = "0" or $s27 = "1" or $s27 = "2" or $s27 = "3" or $s27 = "4" Then + GUICtrlSetBkColor($State27,0xFF0000) + GUICtrlSetColor($State27,$CurrentAccent) + GUICtrlSetData($State27,"OFFLINE") + Else + GUICtrlSetBkColor($State27,0x04B404) + GUICtrlSetColor($State27,$CurrentAccent) + GUICtrlSetData($State27,"ONLINE") + Endif + Endif + if $c28 = "disabled" Then + ; Disabled + Else + $s28 = Ping($c1,$tm) + Sleep(250) + if $s28 = "0" or $s28 = "1" or $s28 = "2" or $s28 = "3" or $s28 = "4" Then + GUICtrlSetBkColor($State28,0xFF0000) + GUICtrlSetColor($State28,$CurrentAccent) + GUICtrlSetData($State28,"OFFLINE") + Else + GUICtrlSetBkColor($State28,0x04B404) + GUICtrlSetColor($State28,$CurrentAccent) + GUICtrlSetData($State28,"ONLINE") + Endif + Endif + if $c29 = "disabled" Then + ; Disabled + Else + $s29 = Ping($c1,$tm) + Sleep(250) + if $s29 = "0" or $s29 = "1" or $s29 = "2" or $s29 = "3" or $s29 = "4" Then + GUICtrlSetBkColor($State29,0xFF0000) + GUICtrlSetColor($State29,$CurrentAccent) + GUICtrlSetData($State29,"OFFLINE") + Else + GUICtrlSetBkColor($State29,0x04B404) + GUICtrlSetColor($State29,$CurrentAccent) + GUICtrlSetData($State29,"ONLINE") + Endif + Endif + if $c30 = "disabled" Then + ; Disabled + Else + $s30 = Ping($c1,$tm) + Sleep(250) + if $s30 = "0" or $s30 = "1" or $s30 = "2" or $s30 = "3" or $s30 = "4" Then + GUICtrlSetBkColor($State30,0xFF0000) + GUICtrlSetColor($State30,$CurrentAccent) + GUICtrlSetData($State30,"OFFLINE") + Else + GUICtrlSetBkColor($State30,0x04B404) + GUICtrlSetColor($State30,$CurrentAccent) + GUICtrlSetData($State30,"ONLINE") + Endif + Endif + if $c31 = "disabled" Then + ; Disabled + Else + $s31 = Ping($c1,$tm) + Sleep(250) + if $s31 = "0" or $s31 = "1" or $s31 = "2" or $s31 = "3" or $s31 = "4" Then + GUICtrlSetBkColor($State31,0xFF0000) + GUICtrlSetColor($State31,$CurrentAccent) + GUICtrlSetData($State31,"OFFLINE") + Else + GUICtrlSetBkColor($State31,0x04B404) + GUICtrlSetColor($State31,$CurrentAccent) + GUICtrlSetData($State31,"ONLINE") + Endif + Endif + if $c32 = "disabled" Then + ; Disabled + Else + $s32 = Ping($c1,$tm) + Sleep(250) + if $s32 = "0" or $s32 = "1" or $s32 = "2" or $s32 = "3" or $s32 = "4" Then + GUICtrlSetBkColor($State32,0xFF0000) + GUICtrlSetColor($State32,$CurrentAccent) + GUICtrlSetData($State32,"OFFLINE") + Else + GUICtrlSetBkColor($State32,0x04B404) + GUICtrlSetColor($State32,$CurrentAccent) + GUICtrlSetData($State32,"ONLINE") + Endif + Endif + if $c33 = "disabled" Then + ; Disabled + Else + $s33 = Ping($c1,$tm) + Sleep(250) + if $s33 = "0" or $s33 = "1" or $s33 = "2" or $s33 = "3" or $s33 = "4" Then + GUICtrlSetBkColor($State33,0xFF0000) + GUICtrlSetColor($State33,$CurrentAccent) + GUICtrlSetData($State33,"OFFLINE") + Else + GUICtrlSetBkColor($State33,0x04B404) + GUICtrlSetColor($State33,$CurrentAccent) + GUICtrlSetData($State33,"ONLINE") + Endif + Endif + if $c34 = "disabled" Then + ; Disabled + Else + $s34 = Ping($c1,$tm) + Sleep(250) + if $s34 = "0" or $s34 = "1" or $s34 = "2" or $s34 = "3" or $s34 = "4" Then + GUICtrlSetBkColor($State34,0xFF0000) + GUICtrlSetColor($State34,$CurrentAccent) + GUICtrlSetData($State34,"OFFLINE") + Else + GUICtrlSetBkColor($State34,0x04B404) + GUICtrlSetColor($State34,$CurrentAccent) + GUICtrlSetData($State34,"ONLINE") + Endif + Endif + if $c35 = "disabled" Then + ; Disabled + Else + $s35 = Ping($c1,$tm) + Sleep(250) + if $s35 = "0" or $s35 = "1" or $s35 = "2" or $s35 = "3" or $s35 = "4" Then + GUICtrlSetBkColor($State35,0xFF0000) + GUICtrlSetColor($State35,$CurrentAccent) + GUICtrlSetData($State35,"OFFLINE") + Else + GUICtrlSetBkColor($State35,0x04B404) + GUICtrlSetColor($State35,$CurrentAccent) + GUICtrlSetData($State35,"ONLINE") + Endif + Endif + if $c36 = "disabled" Then + ; Disabled + Else + $s36 = Ping($c1,$tm) + Sleep(250) + if $s36 = "0" or $s36 = "1" or $s36 = "2" or $s36 = "3" or $s36 = "4" Then + GUICtrlSetBkColor($State36,0xFF0000) + GUICtrlSetColor($State36,$CurrentAccent) + GUICtrlSetData($State36,"OFFLINE") + Else + GUICtrlSetBkColor($State36,0x04B404) + GUICtrlSetColor($State36,$CurrentAccent) + GUICtrlSetData($State36,"ONLINE") + Endif + Endif + if $c37 = "disabled" Then + ; Disabled + Else + $s37 = Ping($c1,$tm) + Sleep(250) + if $s37 = "0" or $s37 = "1" or $s37 = "2" or $s37 = "3" or $s37 = "4" Then + GUICtrlSetBkColor($State37,0xFF0000) + GUICtrlSetColor($State37,$CurrentAccent) + GUICtrlSetData($State37,"OFFLINE") + Else + GUICtrlSetBkColor($State37,0x04B404) + GUICtrlSetColor($State37,$CurrentAccent) + GUICtrlSetData($State37,"ONLINE") + Endif + Endif + if $c38 = "disabled" Then + ; Disabled + Else + $s38 = Ping($c1,$tm) + Sleep(250) + if $s38 = "0" or $s38 = "1" or $s38 = "2" or $s38 = "3" or $s38 = "4" Then + GUICtrlSetBkColor($State38,0xFF0000) + GUICtrlSetColor($State38,$CurrentAccent) + GUICtrlSetData($State38,"OFFLINE") + Else + GUICtrlSetBkColor($State38,0x04B404) + GUICtrlSetColor($State38,$CurrentAccent) + GUICtrlSetData($State38,"ONLINE") + Endif + Endif + if $c39 = "disabled" Then + ; Disabled + Else + $s39 = Ping($c1,$tm) + Sleep(250) + if $s39 = "0" or $s39 = "1" or $s39 = "2" or $s39 = "3" or $s39 = "4" Then + GUICtrlSetBkColor($State39,0xFF0000) + GUICtrlSetColor($State39,$CurrentAccent) + GUICtrlSetData($State39,"OFFLINE") + Else + GUICtrlSetBkColor($State39,0x04B404) + GUICtrlSetColor($State39,$CurrentAccent) + GUICtrlSetData($State39,"ONLINE") + Endif + Endif + if $c40 = "disabled" Then + ; Disabled + Else + $s40 = Ping($c1,$tm) + Sleep(250) + if $s40 = "0" or $s40 = "1" or $s40 = "2" or $s40 = "3" or $s40 = "4" Then + GUICtrlSetBkColor($State40,0xFF0000) + GUICtrlSetColor($State40,$CurrentAccent) + GUICtrlSetData($State40,"OFFLINE") + Else + GUICtrlSetBkColor($State40,0x04B404) + GUICtrlSetColor($State40,$CurrentAccent) + GUICtrlSetData($State40,"ONLINE") + Endif + Endif + if $c41 = "disabled" Then + ; Disabled + Else + $s41 = Ping($c1,$tm) + Sleep(250) + if $s41 = "0" or $s41 = "1" or $s41 = "2" or $s41 = "3" or $s41 = "4" Then + GUICtrlSetBkColor($State41,0xFF0000) + GUICtrlSetColor($State41,$CurrentAccent) + GUICtrlSetData($State41,"OFFLINE") + Else + GUICtrlSetBkColor($State41,0x04B404) + GUICtrlSetColor($State41,$CurrentAccent) + GUICtrlSetData($State41,"ONLINE") + Endif + Endif + if $c42 = "disabled" Then + ; Disabled + Else + $s42 = Ping($c1,$tm) + Sleep(250) + if $s42 = "0" or $s42 = "1" or $s42 = "2" or $s42 = "3" or $s42 = "4" Then + GUICtrlSetBkColor($State42,0xFF0000) + GUICtrlSetColor($State42,$CurrentAccent) + GUICtrlSetData($State42,"OFFLINE") + Else + GUICtrlSetBkColor($State42,0x04B404) + GUICtrlSetColor($State42,$CurrentAccent) + GUICtrlSetData($State42,"ONLINE") + Endif + Endif + if $c43 = "disabled" Then + ; Disabled + Else + $s43 = Ping($c1,$tm) + Sleep(250) + if $s43 = "0" or $s43 = "1" or $s43 = "2" or $s43 = "3" or $s43 = "4" Then + GUICtrlSetBkColor($State43,0xFF0000) + GUICtrlSetColor($State43,$CurrentAccent) + GUICtrlSetData($State43,"OFFLINE") + Else + GUICtrlSetBkColor($State43,0x04B404) + GUICtrlSetColor($State43,$CurrentAccent) + GUICtrlSetData($State43,"ONLINE") + Endif + Endif + if $c44 = "disabled" Then + ; Disabled + Else + $s44 = Ping($c1,$tm) + Sleep(250) + if $s44 = "0" or $s44 = "1" or $s44 = "2" or $s44 = "3" or $s44 = "4" Then + GUICtrlSetBkColor($State44,0xFF0000) + GUICtrlSetColor($State44,$CurrentAccent) + GUICtrlSetData($State44,"OFFLINE") + Else + GUICtrlSetBkColor($State44,0x04B404) + GUICtrlSetColor($State44,$CurrentAccent) + GUICtrlSetData($State44,"ONLINE") + Endif + Endif + if $c45 = "disabled" Then + ; Disabled + Else + $s45 = Ping($c1,$tm) + Sleep(250) + if $s45 = "0" or $s45 = "1" or $s45 = "2" or $s45 = "3" or $s45 = "4" Then + GUICtrlSetBkColor($State45,0xFF0000) + GUICtrlSetColor($State45,$CurrentAccent) + GUICtrlSetData($State45,"OFFLINE") + Else + GUICtrlSetBkColor($State45,0x04B404) + GUICtrlSetColor($State45,$CurrentAccent) + GUICtrlSetData($State45,"ONLINE") + Endif + Endif + if $c46 = "disabled" Then + ; Disabled + Else + $s46 = Ping($c1,$tm) + Sleep(250) + if $s46 = "0" or $s46 = "1" or $s46 = "2" or $s46 = "3" or $s46 = "4" Then + GUICtrlSetBkColor($State46,0xFF0000) + GUICtrlSetColor($State46,$CurrentAccent) + GUICtrlSetData($State46,"OFFLINE") + Else + GUICtrlSetBkColor($State46,0x04B404) + GUICtrlSetColor($State46,$CurrentAccent) + GUICtrlSetData($State46,"ONLINE") + Endif + Endif + if $c47 = "disabled" Then + ; Disabled + Else + $s47 = Ping($c1,$tm) + Sleep(250) + if $s47 = "0" or $s47 = "1" or $s47 = "2" or $s47 = "3" or $s47 = "4" Then + GUICtrlSetBkColor($State47,0xFF0000) + GUICtrlSetColor($State47,$CurrentAccent) + GUICtrlSetData($State47,"OFFLINE") + Else + GUICtrlSetBkColor($State47,0x04B404) + GUICtrlSetColor($State47,$CurrentAccent) + GUICtrlSetData($State47,"ONLINE") + Endif + Endif + if $c48 = "disabled" Then + ; Disabled + Else + $s48 = Ping($c1,$tm) + Sleep(250) + if $s48 = "0" or $s48 = "1" or $s48 = "2" or $s48 = "3" or $s48 = "4" Then + GUICtrlSetBkColor($State48,0xFF0000) + GUICtrlSetColor($State48,$CurrentAccent) + GUICtrlSetData($State48,"OFFLINE") + Else + GUICtrlSetBkColor($State48,0x04B404) + GUICtrlSetColor($State48,$CurrentAccent) + GUICtrlSetData($State48,"ONLINE") + Endif + Endif + if $c49 = "disabled" Then + ; Disabled + Else + $s49 = Ping($c1,$tm) + Sleep(250) + if $s49 = "0" or $s49 = "1" or $s49 = "2" or $s49 = "3" or $s49 = "4" Then + GUICtrlSetBkColor($State49,0xFF0000) + GUICtrlSetColor($State49,$CurrentAccent) + GUICtrlSetData($State49,"OFFLINE") + Else + GUICtrlSetBkColor($State49,0x04B404) + GUICtrlSetColor($State49,$CurrentAccent) + GUICtrlSetData($State49,"ONLINE") + Endif + Endif + if $c50 = "disabled" Then + ; Disabled + Else + $s50 = Ping($c1,$tm) + Sleep(250) + if $s50 = "0" or $s50 = "1" or $s50 = "2" or $s50 = "3" or $s50 = "4" Then + GUICtrlSetBkColor($State50,0xFF0000) + GUICtrlSetColor($State50,$CurrentAccent) + GUICtrlSetData($State50,"OFFLINE") + Else + GUICtrlSetBkColor($State50,0x04B404) + GUICtrlSetColor($State50,$CurrentAccent) + GUICtrlSetData($State50,"ONLINE") + Endif + Endif + if $c51 = "disabled" Then + ; Disabled + Else + $s51 = Ping($c1,$tm) + Sleep(250) + if $s51 = "0" or $s51 = "1" or $s51 = "2" or $s51 = "3" or $s51 = "4" Then + GUICtrlSetBkColor($State51,0xFF0000) + GUICtrlSetColor($State51,$CurrentAccent) + GUICtrlSetData($State51,"OFFLINE") + Else + GUICtrlSetBkColor($State51,0x04B404) + GUICtrlSetColor($State51,$CurrentAccent) + GUICtrlSetData($State51,"ONLINE") + Endif + Endif + Wend + EndSwitch + WEnd diff --git a/NAG Leo/NAG Leo.exe b/NAG Leo/NAG Leo.exe new file mode 100755 index 0000000..4940e76 Binary files /dev/null and b/NAG Leo/NAG Leo.exe differ diff --git a/NAG Leo/NAG_Stop.Exe b/NAG Leo/NAG_Stop.Exe new file mode 100755 index 0000000..ff2bf2e Binary files /dev/null and b/NAG Leo/NAG_Stop.Exe differ diff --git a/NAG Leo/Releases/.media b/NAG Leo/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/NAG Leo/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) + diff --git a/NAG Leo/Releases/NAG_Stop.Exe b/NAG Leo/Releases/NAG_Stop.Exe new file mode 100755 index 0000000..5a61e66 Binary files /dev/null and b/NAG Leo/Releases/NAG_Stop.Exe differ diff --git a/NAG Leo/Supervision.au3 b/NAG Leo/Supervision.au3 new file mode 100755 index 0000000..8fde6f2 --- /dev/null +++ b/NAG Leo/Supervision.au3 @@ -0,0 +1,1567 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=SupervisionNAGLeo.ico +#AutoIt3Wrapper_Outfile_x64=Releases\NAG.exe +#AutoIt3Wrapper_Res_Comment=NAGLeo - Supervision Embarquée Portable +#AutoIt3Wrapper_Res_Description=NAGLeo - Supervision Embarquée Portable +#AutoIt3Wrapper_Res_Fileversion=1.0.0.18 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=NAGLeo +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +#include +#include +#include +#Region ### START Koda GUI section ### Form=H:\Supervision\Form1.kxf + +if FileExists(@ScriptDir & "\NAG_Stop.exe") Then + Run("NAG_Stop.exe") +Else + MsgBox(0+16,"Error","This software is incomplete. Recheck your Download source.") + Exit(1) +Endif +Global $Supervision = GUICreate("Supervision NAG-Leo", 1148, 657, 191, 145) +GUISetBkColor(0xFFFFFF,$Supervision) +GUISetFont(9, 900,"", "Arial", $Supervision) + +$defaulthost = "disabled" +$defaulttimeout = "2000" +$config = @ScriptDir & "\Hosts.ini" +$timeout = @ScriptDir & "\Timeout.ini" + +If FileExists($timeout) Then + ; Already Configured +Else + IniWrite($timeout,"Config TimeOut NagLeo","TimeOut(ms)",$defaulttimeout) +Endif + +$tm = IniRead($timeout,"Config TimeOut NagLeo","TimeOut(ms)",$defaulttimeout) + +if FileExists($config) Then + ; Already Configured +Else + IniWrite($config,"Hosts NagLeo","Host-1",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-2",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-3",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-4",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-5",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-6",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-7",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-8",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-9",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-10",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-11",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-12",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-13",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-14",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-15",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-16",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-17",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-18",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-19",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-20",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-21",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-22",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-23",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-24",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-25",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-26",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-27",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-28",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-29",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-30",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-31",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-32",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-33",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-34",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-35",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-36",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-37",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-38",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-39",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-40",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-41",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-42",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-43",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-44",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-45",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-46",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-47",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-48",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-49",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-50",$defaulthost) + IniWrite($config,"Hosts NagLeo","Host-51",$defaulthost) +Endif + +; First init +$c1 = IniRead($config,"Hosts NagLeo","Host-1",$defaulthost) +$c2 = IniRead($config,"Hosts NagLeo","Host-2",$defaulthost) +$c3 = IniRead($config,"Hosts NagLeo","Host-3",$defaulthost) +$c4 = IniRead($config,"Hosts NagLeo","Host-4",$defaulthost) +$c5 = IniRead($config,"Hosts NagLeo","Host-5",$defaulthost) +$c6 = IniRead($config,"Hosts NagLeo","Host-6",$defaulthost) +$c7 = IniRead($config,"Hosts NagLeo","Host-7",$defaulthost) +$c8 = IniRead($config,"Hosts NagLeo","Host-8",$defaulthost) +$c9 = IniRead($config,"Hosts NagLeo","Host-9",$defaulthost) +$c10 = IniRead($config,"Hosts NagLeo","Host-10",$defaulthost) +$c11 = IniRead($config,"Hosts NagLeo","Host-11",$defaulthost) +$c12 = IniRead($config,"Hosts NagLeo","Host-12",$defaulthost) +$c13 = IniRead($config,"Hosts NagLeo","Host-13",$defaulthost) +$c14 = IniRead($config,"Hosts NagLeo","Host-14",$defaulthost) +$c15 = IniRead($config,"Hosts NagLeo","Host-15",$defaulthost) +$c16 = IniRead($config,"Hosts NagLeo","Host-16",$defaulthost) +$c17 = IniRead($config,"Hosts NagLeo","Host-17",$defaulthost) +$c18 = IniRead($config,"Hosts NagLeo","Host-18",$defaulthost) +$c19 = IniRead($config,"Hosts NagLeo","Host-19",$defaulthost) +$c20 = IniRead($config,"Hosts NagLeo","Host-20",$defaulthost) +$c21 = IniRead($config,"Hosts NagLeo","Host-21",$defaulthost) +$c22 = IniRead($config,"Hosts NagLeo","Host-22",$defaulthost) +$c23 = IniRead($config,"Hosts NagLeo","Host-23",$defaulthost) +$c24 = IniRead($config,"Hosts NagLeo","Host-24",$defaulthost) +$c25 = IniRead($config,"Hosts NagLeo","Host-25",$defaulthost) +$c26 = IniRead($config,"Hosts NagLeo","Host-26",$defaulthost) +$c27 = IniRead($config,"Hosts NagLeo","Host-27",$defaulthost) +$c28 = IniRead($config,"Hosts NagLeo","Host-28",$defaulthost) +$c29 = IniRead($config,"Hosts NagLeo","Host-29",$defaulthost) +$c30 = IniRead($config,"Hosts NagLeo","Host-30",$defaulthost) +$c31 = IniRead($config,"Hosts NagLeo","Host-31",$defaulthost) +$c32 = IniRead($config,"Hosts NagLeo","Host-32",$defaulthost) +$c33 = IniRead($config,"Hosts NagLeo","Host-33",$defaulthost) +$c34 = IniRead($config,"Hosts NagLeo","Host-34",$defaulthost) +$c35 = IniRead($config,"Hosts NagLeo","Host-35",$defaulthost) +$c36 = IniRead($config,"Hosts NagLeo","Host-36",$defaulthost) +$c37 = IniRead($config,"Hosts NagLeo","Host-37",$defaulthost) +$c38 = IniRead($config,"Hosts NagLeo","Host-38",$defaulthost) +$c39 = IniRead($config,"Hosts NagLeo","Host-39",$defaulthost) +$c40 = IniRead($config,"Hosts NagLeo","Host-40",$defaulthost) +$c41 = IniRead($config,"Hosts NagLeo","Host-41",$defaulthost) +$c42 = IniRead($config,"Hosts NagLeo","Host-42",$defaulthost) +$c43 = IniRead($config,"Hosts NagLeo","Host-43",$defaulthost) +$c44 = IniRead($config,"Hosts NagLeo","Host-44",$defaulthost) +$c45 = IniRead($config,"Hosts NagLeo","Host-45",$defaulthost) +$c46 = IniRead($config,"Hosts NagLeo","Host-46",$defaulthost) +$c47 = IniRead($config,"Hosts NagLeo","Host-47",$defaulthost) +$c48 = IniRead($config,"Hosts NagLeo","Host-48",$defaulthost) +$c49 = IniRead($config,"Hosts NagLeo","Host-49",$defaulthost) +$c50 = IniRead($config,"Hosts NagLeo","Host-50",$defaulthost) +$c51 = IniRead($config,"Hosts NagLeo","Host-51",$defaulthost) + +; Menu +Global $Rclick_Files = GUICtrlCreateContextMenu() +Global $Rclick_Ver = GUICtrlCreateMenuItem("Version",$Rclick_Files) +Global $Rclick_Dev = GUICtrlCreateMenuItem("Developer",$Rclick_Files) + +; Zone 1 +; States +Global $State1 = GUICtrlCreateButton("NOT DEFINED", 8, 16, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State2 = GUICtrlCreateButton("NOT DEFINED", 8, 40, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State3 = GUICtrlCreateButton("NOT DEFINED", 8, 64, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State4 = GUICtrlCreateButton("NOT DEFINED", 8, 88, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State5 = GUICtrlCreateButton("NOT DEFINED", 8, 112, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State6 = GUICtrlCreateButton("NOT DEFINED", 8, 136, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State7 = GUICtrlCreateButton("NOT DEFINED", 8, 160, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State8 = GUICtrlCreateButton("NOT DEFINED", 8, 184, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State9 = GUICtrlCreateButton("NOT DEFINED", 8, 208, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State10 = GUICtrlCreateButton("NOT DEFINED", 8, 232, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State11 = GUICtrlCreateButton("NOT DEFINED", 8, 256, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State12 = GUICtrlCreateButton("NOT DEFINED", 8, 280, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State13 = GUICtrlCreateButton("NOT DEFINED", 8, 304, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State14 = GUICtrlCreateButton("NOT DEFINED", 8, 328, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State15 = GUICtrlCreateButton("NOT DEFINED", 8, 352, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State16 = GUICtrlCreateButton("NOT DEFINED", 8, 376, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State17 = GUICtrlCreateButton("NOT DEFINED", 8, 400, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State18 = GUICtrlCreateButton("NOT DEFINED", 8, 424, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State19 = GUICtrlCreateButton("NOT DEFINED", 8, 448, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State20 = GUICtrlCreateButton("NOT DEFINED", 8, 472, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State21 = GUICtrlCreateButton("NOT DEFINED", 8, 496, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State22 = GUICtrlCreateButton("NOT DEFINED", 8, 520, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State23 = GUICtrlCreateButton("NOT DEFINED", 8, 544, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State24 = GUICtrlCreateButton("NOT DEFINED", 8, 568, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State25 = GUICtrlCreateButton("NOT DEFINED", 8, 592, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State26 = GUICtrlCreateButton("NOT DEFINED", 8, 616, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) + +; Names +Global $Name1 = GUICtrlCreateButton($c1, 137, 16, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name2 = GUICtrlCreateButton($c2, 137, 40, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name3 = GUICtrlCreateButton($c3, 137, 64, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name4 = GUICtrlCreateButton($c4, 137, 88, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name5 = GUICtrlCreateButton($c5, 137, 112, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name6 = GUICtrlCreateButton($c6, 137, 136, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name7 = GUICtrlCreateButton($c7, 137, 160, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name8 = GUICtrlCreateButton($c8, 137, 184, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name9 = GUICtrlCreateButton($c9, 137, 208, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name10 = GUICtrlCreateButton($c10, 137, 232, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name11 = GUICtrlCreateButton($c11, 137, 256, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name12 = GUICtrlCreateButton($c12, 137, 280, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name13 = GUICtrlCreateButton($c13, 137, 304, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name14 = GUICtrlCreateButton($c14, 137, 328, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name15 = GUICtrlCreateButton($c15, 137, 352, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name16 = GUICtrlCreateButton($c16, 137, 376, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name17 = GUICtrlCreateButton($c17, 137, 400, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name18 = GUICtrlCreateButton($c18, 137, 424, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name19 = GUICtrlCreateButton($c19, 137, 448, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name20 = GUICtrlCreateButton($c20, 137, 472, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name21 = GUICtrlCreateButton($c21, 137, 496, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name22 = GUICtrlCreateButton($c22, 137, 520, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name23 = GUICtrlCreateButton($c23, 137, 544, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name24 = GUICtrlCreateButton($c24, 137, 568, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name25 = GUICtrlCreateButton($c25, 137, 592, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name26 = GUICtrlCreateButton($c26, 137, 616, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) + +; Zone 2 +; States +Global $State27 = GUICtrlCreateButton("NOT DEFINED", 584, 16, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State28 = GUICtrlCreateButton("NOT DEFINED", 584, 40, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State29 = GUICtrlCreateButton("NOT DEFINED", 584, 64, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State30 = GUICtrlCreateButton("NOT DEFINED", 584, 88, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State31 = GUICtrlCreateButton("NOT DEFINED", 584, 112, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State32 = GUICtrlCreateButton("NOT DEFINED", 584, 136, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State33 = GUICtrlCreateButton("NOT DEFINED", 584, 160, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State34 = GUICtrlCreateButton("NOT DEFINED", 584, 184, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State35 = GUICtrlCreateButton("NOT DEFINED", 584, 208, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State36 = GUICtrlCreateButton("NOT DEFINED", 584, 232, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State37 = GUICtrlCreateButton("NOT DEFINED", 584, 256, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State38 = GUICtrlCreateButton("NOT DEFINED", 584, 280, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State39 = GUICtrlCreateButton("NOT DEFINED", 584, 304, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State40 = GUICtrlCreateButton("NOT DEFINED", 584, 328, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State41 = GUICtrlCreateButton("NOT DEFINED", 584, 352, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State42 = GUICtrlCreateButton("NOT DEFINED", 584, 376, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State43 = GUICtrlCreateButton("NOT DEFINED", 584, 400, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State44 = GUICtrlCreateButton("NOT DEFINED", 584, 424, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State45 = GUICtrlCreateButton("NOT DEFINED", 584, 448, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State46 = GUICtrlCreateButton("NOT DEFINED", 584, 472, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State47 = GUICtrlCreateButton("NOT DEFINED", 584, 496, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State48 = GUICtrlCreateButton("NOT DEFINED", 584, 520, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State49 = GUICtrlCreateButton("NOT DEFINED", 584, 544, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State50 = GUICtrlCreateButton("NOT DEFINED", 584, 568, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $State51 = GUICtrlCreateButton("NOT DEFINED", 584, 592, 129, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) + +; Names +Global $Name27 = GUICtrlCreateButton($c27, 713, 16, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name28 = GUICtrlCreateButton($c28, 713, 40, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name29 = GUICtrlCreateButton($c29, 713, 64, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name30 = GUICtrlCreateButton($c30, 713, 88, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name31 = GUICtrlCreateButton($c31, 713, 112, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name32 = GUICtrlCreateButton($c32, 713, 136, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name33 = GUICtrlCreateButton($c33, 713, 160, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name34 = GUICtrlCreateButton($c34, 713, 184, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name35 = GUICtrlCreateButton($c35, 713, 208, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name36 = GUICtrlCreateButton($c36, 713, 232, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name37 = GUICtrlCreateButton($c37, 713, 256, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name38 = GUICtrlCreateButton($c38, 713, 280, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name39 = GUICtrlCreateButton($c39, 713, 304, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name40 = GUICtrlCreateButton($c40, 713, 328, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name41 = GUICtrlCreateButton($c41, 713, 352, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name42 = GUICtrlCreateButton($c42, 713, 376, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name43 = GUICtrlCreateButton($c43, 713, 400, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name44 = GUICtrlCreateButton($c44, 713, 424, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name45 = GUICtrlCreateButton($c45, 713, 448, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name46 = GUICtrlCreateButton($c46, 713, 472, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name47 = GUICtrlCreateButton($c47, 713, 496, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name48 = GUICtrlCreateButton($c48, 713, 520, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name49 = GUICtrlCreateButton($c49, 713, 544, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name50 = GUICtrlCreateButton($c50, 713, 568, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Name51 = GUICtrlCreateButton($c51, 713, 592, 426, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $StartSupervision = GUICtrlCreateButton("START SUPERVISION", 584, 616, 555, 25) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +Global $Separator = GUICtrlCreateButton("", 570, -8, 8, 700) +GUICtrlSetBkColor(-1,0xFFFFFF) +GUICtrlSetColor(-1,0x000000) +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +if $c1 = "disabled" Then + GUICtrlSetData($State1,"DISABLED") + GUICtrlSetState($State1, $GUI_DISABLE) + GUICtrlSetBkColor($State1, 0xFFFF00) +EndIf + +if $c2 = "disabled" Then + GUICtrlSetData($State2,"DISABLED") + GUICtrlSetState($State2, $GUI_DISABLE) + GUICtrlSetBkColor($State2, 0xFFFF00) +EndIf + +if $c3 = "disabled" Then + GUICtrlSetData($State3,"DISABLED") + GUICtrlSetState($State3, $GUI_DISABLE) + GUICtrlSetBkColor($State3, 0xFFFF00) +EndIf + +if $c4 = "disabled" Then + GUICtrlSetData($State4,"DISABLED") + GUICtrlSetState($State4, $GUI_DISABLE) + GUICtrlSetBkColor($State4, 0xFFFF00) +EndIf + +if $c5 = "disabled" Then + GUICtrlSetData($State5,"DISABLED") + GUICtrlSetState($State5, $GUI_DISABLE) + GUICtrlSetBkColor($State5, 0xFFFF00) +EndIf + +if $c6 = "disabled" Then + GUICtrlSetData($State6,"DISABLED") + GUICtrlSetState($State6, $GUI_DISABLE) + GUICtrlSetBkColor($State6, 0xFFFF00) +EndIf + +if $c7 = "disabled" Then + GUICtrlSetData($State7,"DISABLED") + GUICtrlSetState($State7, $GUI_DISABLE) + GUICtrlSetBkColor($State7, 0xFFFF00) +EndIf + +if $c8 = "disabled" Then + GUICtrlSetData($State8,"DISABLED") + GUICtrlSetState($State8, $GUI_DISABLE) + GUICtrlSetBkColor($State8, 0xFFFF00) +EndIf + +if $c9 = "disabled" Then + GUICtrlSetData($State9,"DISABLED") + GUICtrlSetState($State9, $GUI_DISABLE) + GUICtrlSetBkColor($State9, 0xFFFF00) +EndIf + +if $c10 = "disabled" Then + GUICtrlSetData($State10,"DISABLED") + GUICtrlSetState($State10, $GUI_DISABLE) + GUICtrlSetBkColor($State10, 0xFFFF00) +EndIf + +if $c11 = "disabled" Then + GUICtrlSetData($State11,"DISABLED") + GUICtrlSetState($State11, $GUI_DISABLE) + GUICtrlSetBkColor($State11, 0xFFFF00) +EndIf + +if $c12 = "disabled" Then + GUICtrlSetData($State12,"DISABLED") + GUICtrlSetState($State12, $GUI_DISABLE) + GUICtrlSetBkColor($State12, 0xFFFF00) +EndIf + +if $c13 = "disabled" Then + GUICtrlSetData($State13,"DISABLED") + GUICtrlSetState($State13, $GUI_DISABLE) + GUICtrlSetBkColor($State13, 0xFFFF00) +EndIf + +if $c14 = "disabled" Then + GUICtrlSetData($State14,"DISABLED") + GUICtrlSetState($State14, $GUI_DISABLE) + GUICtrlSetBkColor($State14, 0xFFFF00) +EndIf + +if $c15 = "disabled" Then + GUICtrlSetData($State15,"DISABLED") + GUICtrlSetState($State15, $GUI_DISABLE) + GUICtrlSetBkColor($State15, 0xFFFF00) +EndIf + +if $c16 = "disabled" Then + GUICtrlSetData($State16,"DISABLED") + GUICtrlSetState($State16, $GUI_DISABLE) + GUICtrlSetBkColor($State16, 0xFFFF00) +EndIf + +if $c17 = "disabled" Then + GUICtrlSetData($State17,"DISABLED") + GUICtrlSetState($State17, $GUI_DISABLE) + GUICtrlSetBkColor($State17, 0xFFFF00) +EndIf + +if $c18 = "disabled" Then + GUICtrlSetData($State18,"DISABLED") + GUICtrlSetState($State18, $GUI_DISABLE) + GUICtrlSetBkColor($State18, 0xFFFF00) +EndIf + +if $c19 = "disabled" Then + GUICtrlSetData($State19,"DISABLED") + GUICtrlSetState($State19, $GUI_DISABLE) + GUICtrlSetBkColor($State19, 0xFFFF00) +EndIf + +if $c20 = "disabled" Then + GUICtrlSetData($State20,"DISABLED") + GUICtrlSetState($State20, $GUI_DISABLE) + GUICtrlSetBkColor($State20, 0xFFFF00) +EndIf +if $c21 = "disabled" Then + GUICtrlSetData($State21,"DISABLED") + GUICtrlSetState($State21, $GUI_DISABLE) + GUICtrlSetBkColor($State21, 0xFFFF00) +EndIf + +if $c22 = "disabled" Then + GUICtrlSetData($State22,"DISABLED") + GUICtrlSetState($State22, $GUI_DISABLE) + GUICtrlSetBkColor($State22, 0xFFFF00) +EndIf + +if $c23 = "disabled" Then + GUICtrlSetData($State23,"DISABLED") + GUICtrlSetState($State23, $GUI_DISABLE) + GUICtrlSetBkColor($State23, 0xFFFF00) +EndIf + +if $c24 = "disabled" Then + GUICtrlSetData($State24,"DISABLED") + GUICtrlSetState($State24, $GUI_DISABLE) + GUICtrlSetBkColor($State24, 0xFFFF00) +EndIf + +if $c25 = "disabled" Then + GUICtrlSetData($State25,"DISABLED") + GUICtrlSetState($State25, $GUI_DISABLE) + GUICtrlSetBkColor($State25, 0xFFFF00) +EndIf + +if $c26 = "disabled" Then + GUICtrlSetData($State26,"DISABLED") + GUICtrlSetState($State26, $GUI_DISABLE) + GUICtrlSetBkColor($State26, 0xFFFF00) +EndIf + +if $c27 = "disabled" Then + GUICtrlSetData($State27,"DISABLED") + GUICtrlSetState($State27, $GUI_DISABLE) + GUICtrlSetBkColor($State27, 0xFFFF00) +EndIf + +if $c28 = "disabled" Then + GUICtrlSetData($State28,"DISABLED") + GUICtrlSetState($State28, $GUI_DISABLE) + GUICtrlSetBkColor($State28, 0xFFFF00) +EndIf + +if $c29 = "disabled" Then + GUICtrlSetData($State29,"DISABLED") + GUICtrlSetState($State29, $GUI_DISABLE) + GUICtrlSetBkColor($State29, 0xFFFF00) +EndIf + +if $c30 = "disabled" Then + GUICtrlSetData($State30,"DISABLED") + GUICtrlSetState($State30, $GUI_DISABLE) + GUICtrlSetBkColor($State30, 0xFFFF00) +EndIf +if $c31 = "disabled" Then + GUICtrlSetData($State31,"DISABLED") + GUICtrlSetState($State31, $GUI_DISABLE) + GUICtrlSetBkColor($State31, 0xFFFF00) +EndIf + +if $c32 = "disabled" Then + GUICtrlSetData($State32,"DISABLED") + GUICtrlSetState($State32, $GUI_DISABLE) + GUICtrlSetBkColor($State32, 0xFFFF00) +EndIf + +if $c33 = "disabled" Then + GUICtrlSetData($State33,"DISABLED") + GUICtrlSetState($State33, $GUI_DISABLE) + GUICtrlSetBkColor($State33, 0xFFFF00) +EndIf + +if $c34 = "disabled" Then + GUICtrlSetData($State34,"DISABLED") + GUICtrlSetState($State34, $GUI_DISABLE) + GUICtrlSetBkColor($State34, 0xFFFF00) +EndIf + +if $c35 = "disabled" Then + GUICtrlSetData($State35,"DISABLED") + GUICtrlSetState($State35, $GUI_DISABLE) + GUICtrlSetBkColor($State35, 0xFFFF00) +EndIf + +if $c36 = "disabled" Then + GUICtrlSetData($State36,"DISABLED") + GUICtrlSetState($State36, $GUI_DISABLE) + GUICtrlSetBkColor($State36, 0xFFFF00) +EndIf + +if $c37 = "disabled" Then + GUICtrlSetData($State37,"DISABLED") + GUICtrlSetState($State37, $GUI_DISABLE) + GUICtrlSetBkColor($State37, 0xFFFF00) +EndIf + +if $c38 = "disabled" Then + GUICtrlSetData($State38,"DISABLED") + GUICtrlSetState($State38, $GUI_DISABLE) + GUICtrlSetBkColor($State38, 0xFFFF00) +EndIf + +if $c39 = "disabled" Then + GUICtrlSetData($State39,"DISABLED") + GUICtrlSetState($State39, $GUI_DISABLE) + GUICtrlSetBkColor($State39, 0xFFFF00) +EndIf + +if $c40 = "disabled" Then + GUICtrlSetData($State40,"DISABLED") + GUICtrlSetState($State40, $GUI_DISABLE) + GUICtrlSetBkColor($State40, 0xFFFF00) +EndIf +if $c41 = "disabled" Then + GUICtrlSetData($State41,"DISABLED") + GUICtrlSetState($State41, $GUI_DISABLE) + GUICtrlSetBkColor($State41, 0xFFFF00) +EndIf + +if $c42 = "disabled" Then + GUICtrlSetData($State42,"DISABLED") + GUICtrlSetState($State42, $GUI_DISABLE) + GUICtrlSetBkColor($State42, 0xFFFF00) +EndIf + +if $c43 = "disabled" Then + GUICtrlSetData($State43,"DISABLED") + GUICtrlSetState($State43, $GUI_DISABLE) + GUICtrlSetBkColor($State43, 0xFFFF00) +EndIf + +if $c44 = "disabled" Then + GUICtrlSetData($State44,"DISABLED") + GUICtrlSetState($State44, $GUI_DISABLE) + GUICtrlSetBkColor($State44, 0xFFFF00) +EndIf + +if $c45 = "disabled" Then + GUICtrlSetData($State45,"DISABLED") + GUICtrlSetState($State45, $GUI_DISABLE) + GUICtrlSetBkColor($State45, 0xFFFF00) +EndIf + +if $c46 = "disabled" Then + GUICtrlSetData($State46,"DISABLED") + GUICtrlSetState($State46, $GUI_DISABLE) + GUICtrlSetBkColor($State46, 0xFFFF00) +EndIf + +if $c47 = "disabled" Then + GUICtrlSetData($State47,"DISABLED") + GUICtrlSetState($State47, $GUI_DISABLE) + GUICtrlSetBkColor($State47, 0xFFFF00) +EndIf + +if $c48 = "disabled" Then + GUICtrlSetData($State48,"DISABLED") + GUICtrlSetState($State48, $GUI_DISABLE) + GUICtrlSetBkColor($State48, 0xFFFF00) +EndIf + +if $c49 = "disabled" Then + GUICtrlSetData($State49,"DISABLED") + GUICtrlSetState($State49, $GUI_DISABLE) + GUICtrlSetBkColor($State49, 0xFFFF00) +EndIf + +if $c50 = "disabled" Then + GUICtrlSetData($State50,"DISABLED") + GUICtrlSetState($State50, $GUI_DISABLE) + GUICtrlSetBkColor($State50, 0xFFFF00) +EndIf + +if $c51 = "disabled" Then + GUICtrlSetData($State51,"DISABLED") + GUICtrlSetState($State51, $GUI_DISABLE) + GUICtrlSetBkColor($State51, 0xFFFF00) +EndIf + +$CurrentVer = FileGetVersion(@AutoItExe) + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + + Case $Rclick_Dev + MsgBox(0,"Software Devs","Tyleo Softwares" & @CRLF & "Tyleo Dev - 2021") + + Case $Rclick_Ver + MsgBox(0,"Software Version","Version : " & $CurrentVer) + + Case $StartSupervision + While 1 + if $c1 = "disabled" Then + ; Disabled + Else + $s1 = Ping($c1,$tm) + Sleep(1250) + if $s1 = "0" or $s1 = "1" or $s1 = "2" or $s1 = "3" or $s1 = "4" Then + GUICtrlSetBkColor($State1,0xFF0000) + GUICtrlSetColor($State1,0xFFFFFF) + GUICtrlSetData($State1,"OFFLINE") + Else + GUICtrlSetBkColor($State1,0x04B404) + GUICtrlSetColor($State1,0xFFFFFF) + GUICtrlSetData($State1,"ONLINE") + Endif + Endif + if $c2 = "disabled" Then + ; Disabled + Else + $s2 = Ping($c2,$tm) + Sleep(250) + if $s2 = "0" or $s2 = "1" or $s2 = "2" or $s2 = "3" or $s2 = "4" Then + GUICtrlSetBkColor($State2,0xFF0000) + GUICtrlSetColor($State2,0xFFFFFF) + GUICtrlSetData($State2,"OFFLINE") + Else + GUICtrlSetBkColor($State2,0x04B404) + GUICtrlSetColor($State2,0xFFFFFF) + GUICtrlSetData($State2,"ONLINE") + Endif + Endif + if $c3 = "disabled" Then + ; Disabled + Else + $s3 = Ping($c3,$tm) + Sleep(250) + if $s3 = "0" or $s3 = "1" or $s3 = "2" or $s3 = "3" or $s3 = "4" Then + GUICtrlSetBkColor($State3,0xFF0000) + GUICtrlSetColor($State3,0xFFFFFF) + GUICtrlSetData($State3,"OFFLINE") + Else + GUICtrlSetBkColor($State3,0x04B404) + GUICtrlSetColor($State3,0xFFFFFF) + GUICtrlSetData($State3,"ONLINE") + Endif + Endif + if $c4 = "disabled" Then + ; Disabled + Else + $s4 = Ping($c4,$tm) + Sleep(250) + if $s4 = "0" or $s4 = "1" or $s4 = "2" or $s4 = "3" or $s4 = "4" Then + GUICtrlSetBkColor($State4,0xFF0000) + GUICtrlSetColor($State4,0xFFFFFF) + GUICtrlSetData($State4,"OFFLINE") + Else + GUICtrlSetBkColor($State4,0x04B404) + GUICtrlSetColor($State4,0xFFFFFF) + GUICtrlSetData($State4,"ONLINE") + Endif + Endif + if $c5 = "disabled" Then + ; Disabled + Else + $s5 = Ping($c5,$tm) + Sleep(250) + if $s5 = "0" or $s5 = "1" or $s5 = "2" or $s5 = "3" or $s5 = "4" Then + GUICtrlSetBkColor($State5,0xFF0000) + GUICtrlSetColor($State5,0xFFFFFF) + GUICtrlSetData($State5,"OFFLINE") + Else + GUICtrlSetBkColor($State5,0x04B404) + GUICtrlSetColor($State5,0xFFFFFF) + GUICtrlSetData($State5,"ONLINE") + Endif + Endif + if $c6 = "disabled" Then + ; Disabled + Else + $s6 = Ping($c6,$tm) + Sleep(250) + if $s6 = "0" or $s6 = "1" or $s6 = "2" or $s6 = "3" or $s6 = "4" Then + GUICtrlSetBkColor($State6,0xFF0000) + GUICtrlSetColor($State6,0xFFFFFF) + GUICtrlSetData($State6,"OFFLINE") + Else + GUICtrlSetBkColor($State6,0x04B404) + GUICtrlSetColor($State6,0xFFFFFF) + GUICtrlSetData($State6,"ONLINE") + Endif + Endif + if $c7 = "disabled" Then + ; Disabled + Else + $s7 = Ping($c7,$tm) + Sleep(250) + if $s7 = "0" or $s7 = "1" or $s7 = "2" or $s7 = "3" or $s7 = "4" Then + GUICtrlSetBkColor($State7,0xFF0000) + GUICtrlSetColor($State7,0xFFFFFF) + GUICtrlSetData($State7,"OFFLINE") + Else + GUICtrlSetBkColor($State7,0x04B404) + GUICtrlSetColor($State7,0xFFFFFF) + GUICtrlSetData($State7,"ONLINE") + Endif + Endif + if $c8 = "disabled" Then + ; Disabled + Else + $s8 = Ping($c8,$tm) + Sleep(250) + if $s8 = "0" or $s8 = "1" or $s8 = "2" or $s8 = "3" or $s8 = "4" Then + GUICtrlSetBkColor($State8,0xFF0000) + GUICtrlSetColor($State8,0xFFFFFF) + GUICtrlSetData($State8,"OFFLINE") + Else + GUICtrlSetBkColor($State8,0x04B404) + GUICtrlSetColor($State8,0xFFFFFF) + GUICtrlSetData($State8,"ONLINE") + Endif + Endif + if $c9 = "disabled" Then + ; Disabled + Else + $s9 = Ping($c9,$tm) + Sleep(250) + if $s9 = "0" or $s9 = "1" or $s9 = "2" or $s9 = "3" or $s9 = "4" Then + GUICtrlSetBkColor($State9,0xFF0000) + GUICtrlSetColor($State9,0xFFFFFF) + GUICtrlSetData($State9,"OFFLINE") + Else + GUICtrlSetBkColor($State9,0x04B404) + GUICtrlSetColor($State9,0xFFFFFF) + GUICtrlSetData($State9,"ONLINE") + Endif + Endif + if $c10 = "disabled" Then + ; Disabled + Else + $s10 = Ping($c10,$tm) + Sleep(250) + if $s10 = "0" or $s10 = "1" or $s10 = "2" or $s10 = "3" or $s10 = "4" Then + GUICtrlSetBkColor($State10,0xFF0000) + GUICtrlSetColor($State10,0xFFFFFF) + GUICtrlSetData($State10,"OFFLINE") + Else + GUICtrlSetBkColor($State10,0x04B404) + GUICtrlSetColor($State10,0xFFFFFF) + GUICtrlSetData($State10,"ONLINE") + Endif + Endif + if $c11 = "disabled" Then + ; Disabled + Else + $s11 = Ping($c1,$tm) + Sleep(250) + if $s11 = "0" or $s11 = "1" or $s11 = "2" or $s11 = "3" or $s11 = "4" Then + GUICtrlSetBkColor($State11,0xFF0000) + GUICtrlSetColor($State11,0xFFFFFF) + GUICtrlSetData($State11,"OFFLINE") + Else + GUICtrlSetBkColor($State11,0x04B404) + GUICtrlSetColor($State11,0xFFFFFF) + GUICtrlSetData($State11,"ONLINE") + Endif + Endif + if $c12 = "disabled" Then + ; Disabled + Else + $s12 = Ping($c1,$tm) + Sleep(250) + if $s12 = "0" or $s12 = "1" or $s12 = "2" or $s12 = "3" or $s12 = "4" Then + GUICtrlSetBkColor($State12,0xFF0000) + GUICtrlSetColor($State12,0xFFFFFF) + GUICtrlSetData($State12,"OFFLINE") + Else + GUICtrlSetBkColor($State12,0x04B404) + GUICtrlSetColor($State12,0xFFFFFF) + GUICtrlSetData($State12,"ONLINE") + Endif + Endif + if $c13 = "disabled" Then + ; Disabled + Else + $s13 = Ping($c1,$tm) + Sleep(250) + if $s13 = "0" or $s13 = "1" or $s13 = "2" or $s13 = "3" or $s13 = "4" Then + GUICtrlSetBkColor($State13,0xFF0000) + GUICtrlSetColor($State13,0xFFFFFF) + GUICtrlSetData($State13,"OFFLINE") + Else + GUICtrlSetBkColor($State13,0x04B404) + GUICtrlSetColor($State13,0xFFFFFF) + GUICtrlSetData($State13,"ONLINE") + Endif + Endif + if $c14 = "disabled" Then + ; Disabled + Else + $s14 = Ping($c1,$tm) + Sleep(250) + if $s14 = "0" or $s14 = "1" or $s14 = "2" or $s14 = "3" or $s14 = "4" Then + GUICtrlSetBkColor($State14,0xFF0000) + GUICtrlSetColor($State14,0xFFFFFF) + GUICtrlSetData($State14,"OFFLINE") + Else + GUICtrlSetBkColor($State14,0x04B404) + GUICtrlSetColor($State14,0xFFFFFF) + GUICtrlSetData($State14,"ONLINE") + Endif + Endif + if $c15 = "disabled" Then + ; Disabled + Else + $s15 = Ping($c1,$tm) + Sleep(250) + if $s15 = "0" or $s15 = "1" or $s15 = "2" or $s15 = "3" or $s15 = "4" Then + GUICtrlSetBkColor($State15,0xFF0000) + GUICtrlSetColor($State15,0xFFFFFF) + GUICtrlSetData($State15,"OFFLINE") + Else + GUICtrlSetBkColor($State15,0x04B404) + GUICtrlSetColor($State15,0xFFFFFF) + GUICtrlSetData($State15,"ONLINE") + Endif + Endif + if $c16 = "disabled" Then + ; Disabled + Else + $s16 = Ping($c1,$tm) + Sleep(250) + if $s16 = "0" or $s16 = "1" or $s16 = "2" or $s16 = "3" or $s16 = "4" Then + GUICtrlSetBkColor($State16,0xFF0000) + GUICtrlSetColor($State16,0xFFFFFF) + GUICtrlSetData($State16,"OFFLINE") + Else + GUICtrlSetBkColor($State16,0x04B404) + GUICtrlSetColor($State16,0xFFFFFF) + GUICtrlSetData($State16,"ONLINE") + Endif + Endif + if $c17 = "disabled" Then + ; Disabled + Else + $s17 = Ping($c1,$tm) + Sleep(250) + if $s17 = "0" or $s17 = "1" or $s17 = "2" or $s17 = "3" or $s17 = "4" Then + GUICtrlSetBkColor($State17,0xFF0000) + GUICtrlSetColor($State17,0xFFFFFF) + GUICtrlSetData($State17,"OFFLINE") + Else + GUICtrlSetBkColor($State17,0x04B404) + GUICtrlSetColor($State17,0xFFFFFF) + GUICtrlSetData($State17,"ONLINE") + Endif + Endif + if $c18 = "disabled" Then + ; Disabled + Else + $s18 = Ping($c1,$tm) + Sleep(250) + if $s18 = "0" or $s18 = "1" or $s18 = "2" or $s18 = "3" or $s18 = "4" Then + GUICtrlSetBkColor($State18,0xFF0000) + GUICtrlSetColor($State18,0xFFFFFF) + GUICtrlSetData($State18,"OFFLINE") + Else + GUICtrlSetBkColor($State18,0x04B404) + GUICtrlSetColor($State18,0xFFFFFF) + GUICtrlSetData($State18,"ONLINE") + Endif + Endif + if $c19 = "disabled" Then + ; Disabled + Else + $s19 = Ping($c1,$tm) + Sleep(250) + if $s19 = "0" or $s19 = "1" or $s19 = "2" or $s19 = "3" or $s19 = "4" Then + GUICtrlSetBkColor($State19,0xFF0000) + GUICtrlSetColor($State19,0xFFFFFF) + GUICtrlSetData($State19,"OFFLINE") + Else + GUICtrlSetBkColor($State19,0x04B404) + GUICtrlSetColor($State19,0xFFFFFF) + GUICtrlSetData($State19,"ONLINE") + Endif + Endif + if $c20 = "disabled" Then + ; Disabled + Else + $s20 = Ping($c1,$tm) + Sleep(250) + if $s20 = "0" or $s20 = "1" or $s20 = "2" or $s20 = "3" or $s20 = "4" Then + GUICtrlSetBkColor($State20,0xFF0000) + GUICtrlSetColor($State20,0xFFFFFF) + GUICtrlSetData($State20,"OFFLINE") + Else + GUICtrlSetBkColor($State20,0x04B404) + GUICtrlSetColor($State20,0xFFFFFF) + GUICtrlSetData($State20,"ONLINE") + Endif + Endif + if $c21 = "disabled" Then + ; Disabled + Else + $s21 = Ping($c1,$tm) + Sleep(250) + if $s21 = "0" or $s21 = "1" or $s21 = "2" or $s21 = "3" or $s21 = "4" Then + GUICtrlSetBkColor($State21,0xFF0000) + GUICtrlSetColor($State21,0xFFFFFF) + GUICtrlSetData($State21,"OFFLINE") + Else + GUICtrlSetBkColor($State21,0x04B404) + GUICtrlSetColor($State21,0xFFFFFF) + GUICtrlSetData($State21,"ONLINE") + Endif + Endif + if $c22 = "disabled" Then + ; Disabled + Else + $s22 = Ping($c1,$tm) + Sleep(250) + if $s22 = "0" or $s22 = "1" or $s22 = "2" or $s22 = "3" or $s22 = "4" Then + GUICtrlSetBkColor($State22,0xFF0000) + GUICtrlSetColor($State22,0xFFFFFF) + GUICtrlSetData($State22,"OFFLINE") + Else + GUICtrlSetBkColor($State22,0x04B404) + GUICtrlSetColor($State22,0xFFFFFF) + GUICtrlSetData($State22,"ONLINE") + Endif + Endif + if $c23 = "disabled" Then + ; Disabled + Else + $s23 = Ping($c1,$tm) + Sleep(250) + if $s23 = "0" or $s23 = "1" or $s23 = "2" or $s23 = "3" or $s23 = "4" Then + GUICtrlSetBkColor($State23,0xFF0000) + GUICtrlSetColor($State23,0xFFFFFF) + GUICtrlSetData($State23,"OFFLINE") + Else + GUICtrlSetBkColor($State23,0x04B404) + GUICtrlSetColor($State23,0xFFFFFF) + GUICtrlSetData($State23,"ONLINE") + Endif + Endif + if $c24 = "disabled" Then + ; Disabled + Else + $s24 = Ping($c1,$tm) + Sleep(250) + if $s24 = "0" or $s24 = "1" or $s24 = "2" or $s24 = "3" or $s24 = "4" Then + GUICtrlSetBkColor($State24,0xFF0000) + GUICtrlSetColor($State24,0xFFFFFF) + GUICtrlSetData($State24,"OFFLINE") + Else + GUICtrlSetBkColor($State24,0x04B404) + GUICtrlSetColor($State24,0xFFFFFF) + GUICtrlSetData($State24,"ONLINE") + Endif + Endif + if $c25 = "disabled" Then + ; Disabled + Else + $s25 = Ping($c1,$tm) + Sleep(250) + if $s25 = "0" or $s25 = "1" or $s25 = "2" or $s25 = "3" or $s25 = "4" Then + GUICtrlSetBkColor($State25,0xFF0000) + GUICtrlSetColor($State25,0xFFFFFF) + GUICtrlSetData($State25,"OFFLINE") + Else + GUICtrlSetBkColor($State25,0x04B404) + GUICtrlSetColor($State25,0xFFFFFF) + GUICtrlSetData($State25,"ONLINE") + Endif + Endif + if $c26 = "disabled" Then + ; Disabled + Else + $s26 = Ping($c1,$tm) + Sleep(250) + if $s26 = "0" or $s26 = "1" or $s26 = "2" or $s26 = "3" or $s26 = "4" Then + GUICtrlSetBkColor($State26,0xFF0000) + GUICtrlSetColor($State26,0xFFFFFF) + GUICtrlSetData($State26,"OFFLINE") + Else + GUICtrlSetBkColor($State26,0x04B404) + GUICtrlSetColor($State26,0xFFFFFF) + GUICtrlSetData($State26,"ONLINE") + Endif + Endif + if $c27 = "disabled" Then + ; Disabled + Else + $s27 = Ping($c1,$tm) + Sleep(250) + if $s27 = "0" or $s27 = "1" or $s27 = "2" or $s27 = "3" or $s27 = "4" Then + GUICtrlSetBkColor($State27,0xFF0000) + GUICtrlSetColor($State27,0xFFFFFF) + GUICtrlSetData($State27,"OFFLINE") + Else + GUICtrlSetBkColor($State27,0x04B404) + GUICtrlSetColor($State27,0xFFFFFF) + GUICtrlSetData($State27,"ONLINE") + Endif + Endif + if $c28 = "disabled" Then + ; Disabled + Else + $s28 = Ping($c1,$tm) + Sleep(250) + if $s28 = "0" or $s28 = "1" or $s28 = "2" or $s28 = "3" or $s28 = "4" Then + GUICtrlSetBkColor($State28,0xFF0000) + GUICtrlSetColor($State28,0xFFFFFF) + GUICtrlSetData($State28,"OFFLINE") + Else + GUICtrlSetBkColor($State28,0x04B404) + GUICtrlSetColor($State28,0xFFFFFF) + GUICtrlSetData($State28,"ONLINE") + Endif + Endif + if $c29 = "disabled" Then + ; Disabled + Else + $s29 = Ping($c1,$tm) + Sleep(250) + if $s29 = "0" or $s29 = "1" or $s29 = "2" or $s29 = "3" or $s29 = "4" Then + GUICtrlSetBkColor($State29,0xFF0000) + GUICtrlSetColor($State29,0xFFFFFF) + GUICtrlSetData($State29,"OFFLINE") + Else + GUICtrlSetBkColor($State29,0x04B404) + GUICtrlSetColor($State29,0xFFFFFF) + GUICtrlSetData($State29,"ONLINE") + Endif + Endif + if $c30 = "disabled" Then + ; Disabled + Else + $s30 = Ping($c1,$tm) + Sleep(250) + if $s30 = "0" or $s30 = "1" or $s30 = "2" or $s30 = "3" or $s30 = "4" Then + GUICtrlSetBkColor($State30,0xFF0000) + GUICtrlSetColor($State30,0xFFFFFF) + GUICtrlSetData($State30,"OFFLINE") + Else + GUICtrlSetBkColor($State30,0x04B404) + GUICtrlSetColor($State30,0xFFFFFF) + GUICtrlSetData($State30,"ONLINE") + Endif + Endif + if $c31 = "disabled" Then + ; Disabled + Else + $s31 = Ping($c1,$tm) + Sleep(250) + if $s31 = "0" or $s31 = "1" or $s31 = "2" or $s31 = "3" or $s31 = "4" Then + GUICtrlSetBkColor($State31,0xFF0000) + GUICtrlSetColor($State31,0xFFFFFF) + GUICtrlSetData($State31,"OFFLINE") + Else + GUICtrlSetBkColor($State31,0x04B404) + GUICtrlSetColor($State31,0xFFFFFF) + GUICtrlSetData($State31,"ONLINE") + Endif + Endif + if $c32 = "disabled" Then + ; Disabled + Else + $s32 = Ping($c1,$tm) + Sleep(250) + if $s32 = "0" or $s32 = "1" or $s32 = "2" or $s32 = "3" or $s32 = "4" Then + GUICtrlSetBkColor($State32,0xFF0000) + GUICtrlSetColor($State32,0xFFFFFF) + GUICtrlSetData($State32,"OFFLINE") + Else + GUICtrlSetBkColor($State32,0x04B404) + GUICtrlSetColor($State32,0xFFFFFF) + GUICtrlSetData($State32,"ONLINE") + Endif + Endif + if $c33 = "disabled" Then + ; Disabled + Else + $s33 = Ping($c1,$tm) + Sleep(250) + if $s33 = "0" or $s33 = "1" or $s33 = "2" or $s33 = "3" or $s33 = "4" Then + GUICtrlSetBkColor($State33,0xFF0000) + GUICtrlSetColor($State33,0xFFFFFF) + GUICtrlSetData($State33,"OFFLINE") + Else + GUICtrlSetBkColor($State33,0x04B404) + GUICtrlSetColor($State33,0xFFFFFF) + GUICtrlSetData($State33,"ONLINE") + Endif + Endif + if $c34 = "disabled" Then + ; Disabled + Else + $s34 = Ping($c1,$tm) + Sleep(250) + if $s34 = "0" or $s34 = "1" or $s34 = "2" or $s34 = "3" or $s34 = "4" Then + GUICtrlSetBkColor($State34,0xFF0000) + GUICtrlSetColor($State34,0xFFFFFF) + GUICtrlSetData($State34,"OFFLINE") + Else + GUICtrlSetBkColor($State34,0x04B404) + GUICtrlSetColor($State34,0xFFFFFF) + GUICtrlSetData($State34,"ONLINE") + Endif + Endif + if $c35 = "disabled" Then + ; Disabled + Else + $s35 = Ping($c1,$tm) + Sleep(250) + if $s35 = "0" or $s35 = "1" or $s35 = "2" or $s35 = "3" or $s35 = "4" Then + GUICtrlSetBkColor($State35,0xFF0000) + GUICtrlSetColor($State35,0xFFFFFF) + GUICtrlSetData($State35,"OFFLINE") + Else + GUICtrlSetBkColor($State35,0x04B404) + GUICtrlSetColor($State35,0xFFFFFF) + GUICtrlSetData($State35,"ONLINE") + Endif + Endif + if $c36 = "disabled" Then + ; Disabled + Else + $s36 = Ping($c1,$tm) + Sleep(250) + if $s36 = "0" or $s36 = "1" or $s36 = "2" or $s36 = "3" or $s36 = "4" Then + GUICtrlSetBkColor($State36,0xFF0000) + GUICtrlSetColor($State36,0xFFFFFF) + GUICtrlSetData($State36,"OFFLINE") + Else + GUICtrlSetBkColor($State36,0x04B404) + GUICtrlSetColor($State36,0xFFFFFF) + GUICtrlSetData($State36,"ONLINE") + Endif + Endif + if $c37 = "disabled" Then + ; Disabled + Else + $s37 = Ping($c1,$tm) + Sleep(250) + if $s37 = "0" or $s37 = "1" or $s37 = "2" or $s37 = "3" or $s37 = "4" Then + GUICtrlSetBkColor($State37,0xFF0000) + GUICtrlSetColor($State37,0xFFFFFF) + GUICtrlSetData($State37,"OFFLINE") + Else + GUICtrlSetBkColor($State37,0x04B404) + GUICtrlSetColor($State37,0xFFFFFF) + GUICtrlSetData($State37,"ONLINE") + Endif + Endif + if $c38 = "disabled" Then + ; Disabled + Else + $s38 = Ping($c1,$tm) + Sleep(250) + if $s38 = "0" or $s38 = "1" or $s38 = "2" or $s38 = "3" or $s38 = "4" Then + GUICtrlSetBkColor($State38,0xFF0000) + GUICtrlSetColor($State38,0xFFFFFF) + GUICtrlSetData($State38,"OFFLINE") + Else + GUICtrlSetBkColor($State38,0x04B404) + GUICtrlSetColor($State38,0xFFFFFF) + GUICtrlSetData($State38,"ONLINE") + Endif + Endif + if $c39 = "disabled" Then + ; Disabled + Else + $s39 = Ping($c1,$tm) + Sleep(250) + if $s39 = "0" or $s39 = "1" or $s39 = "2" or $s39 = "3" or $s39 = "4" Then + GUICtrlSetBkColor($State39,0xFF0000) + GUICtrlSetColor($State39,0xFFFFFF) + GUICtrlSetData($State39,"OFFLINE") + Else + GUICtrlSetBkColor($State39,0x04B404) + GUICtrlSetColor($State39,0xFFFFFF) + GUICtrlSetData($State39,"ONLINE") + Endif + Endif + if $c40 = "disabled" Then + ; Disabled + Else + $s40 = Ping($c1,$tm) + Sleep(250) + if $s40 = "0" or $s40 = "1" or $s40 = "2" or $s40 = "3" or $s40 = "4" Then + GUICtrlSetBkColor($State40,0xFF0000) + GUICtrlSetColor($State40,0xFFFFFF) + GUICtrlSetData($State40,"OFFLINE") + Else + GUICtrlSetBkColor($State40,0x04B404) + GUICtrlSetColor($State40,0xFFFFFF) + GUICtrlSetData($State40,"ONLINE") + Endif + Endif + if $c41 = "disabled" Then + ; Disabled + Else + $s41 = Ping($c1,$tm) + Sleep(250) + if $s41 = "0" or $s41 = "1" or $s41 = "2" or $s41 = "3" or $s41 = "4" Then + GUICtrlSetBkColor($State41,0xFF0000) + GUICtrlSetColor($State41,0xFFFFFF) + GUICtrlSetData($State41,"OFFLINE") + Else + GUICtrlSetBkColor($State41,0x04B404) + GUICtrlSetColor($State41,0xFFFFFF) + GUICtrlSetData($State41,"ONLINE") + Endif + Endif + if $c42 = "disabled" Then + ; Disabled + Else + $s42 = Ping($c1,$tm) + Sleep(250) + if $s42 = "0" or $s42 = "1" or $s42 = "2" or $s42 = "3" or $s42 = "4" Then + GUICtrlSetBkColor($State42,0xFF0000) + GUICtrlSetColor($State42,0xFFFFFF) + GUICtrlSetData($State42,"OFFLINE") + Else + GUICtrlSetBkColor($State42,0x04B404) + GUICtrlSetColor($State42,0xFFFFFF) + GUICtrlSetData($State42,"ONLINE") + Endif + Endif + if $c43 = "disabled" Then + ; Disabled + Else + $s43 = Ping($c1,$tm) + Sleep(250) + if $s43 = "0" or $s43 = "1" or $s43 = "2" or $s43 = "3" or $s43 = "4" Then + GUICtrlSetBkColor($State43,0xFF0000) + GUICtrlSetColor($State43,0xFFFFFF) + GUICtrlSetData($State43,"OFFLINE") + Else + GUICtrlSetBkColor($State43,0x04B404) + GUICtrlSetColor($State43,0xFFFFFF) + GUICtrlSetData($State43,"ONLINE") + Endif + Endif + if $c44 = "disabled" Then + ; Disabled + Else + $s44 = Ping($c1,$tm) + Sleep(250) + if $s44 = "0" or $s44 = "1" or $s44 = "2" or $s44 = "3" or $s44 = "4" Then + GUICtrlSetBkColor($State44,0xFF0000) + GUICtrlSetColor($State44,0xFFFFFF) + GUICtrlSetData($State44,"OFFLINE") + Else + GUICtrlSetBkColor($State44,0x04B404) + GUICtrlSetColor($State44,0xFFFFFF) + GUICtrlSetData($State44,"ONLINE") + Endif + Endif + if $c45 = "disabled" Then + ; Disabled + Else + $s45 = Ping($c1,$tm) + Sleep(250) + if $s45 = "0" or $s45 = "1" or $s45 = "2" or $s45 = "3" or $s45 = "4" Then + GUICtrlSetBkColor($State45,0xFF0000) + GUICtrlSetColor($State45,0xFFFFFF) + GUICtrlSetData($State45,"OFFLINE") + Else + GUICtrlSetBkColor($State45,0x04B404) + GUICtrlSetColor($State45,0xFFFFFF) + GUICtrlSetData($State45,"ONLINE") + Endif + Endif + if $c46 = "disabled" Then + ; Disabled + Else + $s46 = Ping($c1,$tm) + Sleep(250) + if $s46 = "0" or $s46 = "1" or $s46 = "2" or $s46 = "3" or $s46 = "4" Then + GUICtrlSetBkColor($State46,0xFF0000) + GUICtrlSetColor($State46,0xFFFFFF) + GUICtrlSetData($State46,"OFFLINE") + Else + GUICtrlSetBkColor($State46,0x04B404) + GUICtrlSetColor($State46,0xFFFFFF) + GUICtrlSetData($State46,"ONLINE") + Endif + Endif + if $c47 = "disabled" Then + ; Disabled + Else + $s47 = Ping($c1,$tm) + Sleep(250) + if $s47 = "0" or $s47 = "1" or $s47 = "2" or $s47 = "3" or $s47 = "4" Then + GUICtrlSetBkColor($State47,0xFF0000) + GUICtrlSetColor($State47,0xFFFFFF) + GUICtrlSetData($State47,"OFFLINE") + Else + GUICtrlSetBkColor($State47,0x04B404) + GUICtrlSetColor($State47,0xFFFFFF) + GUICtrlSetData($State47,"ONLINE") + Endif + Endif + if $c48 = "disabled" Then + ; Disabled + Else + $s48 = Ping($c1,$tm) + Sleep(250) + if $s48 = "0" or $s48 = "1" or $s48 = "2" or $s48 = "3" or $s48 = "4" Then + GUICtrlSetBkColor($State48,0xFF0000) + GUICtrlSetColor($State48,0xFFFFFF) + GUICtrlSetData($State48,"OFFLINE") + Else + GUICtrlSetBkColor($State48,0x04B404) + GUICtrlSetColor($State48,0xFFFFFF) + GUICtrlSetData($State48,"ONLINE") + Endif + Endif + if $c49 = "disabled" Then + ; Disabled + Else + $s49 = Ping($c1,$tm) + Sleep(250) + if $s49 = "0" or $s49 = "1" or $s49 = "2" or $s49 = "3" or $s49 = "4" Then + GUICtrlSetBkColor($State49,0xFF0000) + GUICtrlSetColor($State49,0xFFFFFF) + GUICtrlSetData($State49,"OFFLINE") + Else + GUICtrlSetBkColor($State49,0x04B404) + GUICtrlSetColor($State49,0xFFFFFF) + GUICtrlSetData($State49,"ONLINE") + Endif + Endif + if $c50 = "disabled" Then + ; Disabled + Else + $s50 = Ping($c1,$tm) + Sleep(250) + if $s50 = "0" or $s50 = "1" or $s50 = "2" or $s50 = "3" or $s50 = "4" Then + GUICtrlSetBkColor($State50,0xFF0000) + GUICtrlSetColor($State50,0xFFFFFF) + GUICtrlSetData($State50,"OFFLINE") + Else + GUICtrlSetBkColor($State50,0x04B404) + GUICtrlSetColor($State50,0xFFFFFF) + GUICtrlSetData($State50,"ONLINE") + Endif + Endif + if $c51 = "disabled" Then + ; Disabled + Else + $s51 = Ping($c1,$tm) + Sleep(250) + if $s51 = "0" or $s51 = "1" or $s51 = "2" or $s51 = "3" or $s51 = "4" Then + GUICtrlSetBkColor($State51,0xFF0000) + GUICtrlSetColor($State51,0xFFFFFF) + GUICtrlSetData($State51,"OFFLINE") + Else + GUICtrlSetBkColor($State51,0x04B404) + GUICtrlSetColor($State51,0xFFFFFF) + GUICtrlSetData($State51,"ONLINE") + Endif + Endif + Wend + EndSwitch + WEnd + \ No newline at end of file diff --git a/NAG Leo/SupervisionNAGLeo.ico b/NAG Leo/SupervisionNAGLeo.ico new file mode 100755 index 0000000..157d805 Binary files /dev/null and b/NAG Leo/SupervisionNAGLeo.ico differ diff --git a/NAG Leo/SupervisionNAGLeo_stop.ico b/NAG Leo/SupervisionNAGLeo_stop.ico new file mode 100755 index 0000000..694c3b9 Binary files /dev/null and b/NAG Leo/SupervisionNAGLeo_stop.ico differ diff --git a/NAG Leo/Supervision_Control.au3 b/NAG Leo/Supervision_Control.au3 new file mode 100755 index 0000000..274c178 --- /dev/null +++ b/NAG Leo/Supervision_Control.au3 @@ -0,0 +1,34 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=SupervisionNAGLeo_stop.ico +#AutoIt3Wrapper_Outfile_x64=Releases\NAG_Stop.Exe +#AutoIt3Wrapper_Res_Comment=NAGLeo - Stop +#AutoIt3Wrapper_Res_Description=NAGLeo - Stop +#AutoIt3Wrapper_Res_Fileversion=1.0.0.1 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=NAGLeo - Stop +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +#include +#include +#include +#Region ### START Koda GUI section ### Form= +Global $Form2 = GUICreate("", 169, 47, 302, 218) +Global $Button1 = GUICtrlCreateButton("STOP", 8, 8, 153, 33) +GUICtrlSetFont(-1, 20, 400, 0, "Segoe UI") +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +While ProcessExists("NAG.exe") + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + ProcessClose("NAG.exe") + Exit + Case $Button1 + ProcessClose("NAG.exe") + + EndSwitch +WEnd diff --git a/NAG Leo/Timeout.ini b/NAG Leo/Timeout.ini new file mode 100755 index 0000000..dba1d33 --- /dev/null +++ b/NAG Leo/Timeout.ini @@ -0,0 +1,2 @@ +[Config TimeOut NagLeo] +TimeOut(ms)=2000 diff --git a/Notepad XS/Extensions.au3 b/Notepad XS/Extensions.au3 new file mode 100755 index 0000000..4c3ee19 --- /dev/null +++ b/Notepad XS/Extensions.au3 @@ -0,0 +1,34 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +; Color Accent +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +; Software Base Details +Func GetSoftDetails($Exe,$Stage) + Global $CurrentVersion,$CurrentName,$CurrentBaseVersion + $CurrentVersion = FileGetVersion($Exe,$FV_FILEVERSION) + $CurrentBaseVersion = FileGetVersion($Exe,$FV_PRODUCTVERSION) + $CurrentName = FileGetVersion($Exe,$FV_PRODUCTNAME) + if $Stage = "BETA" Then + $CurrentVersion = $CurrentVersion & "-beta" + Elseif $Stage = "RELEASE" or $Stage = "STABLE" Then + $CurrentVersion = $CurrentVersion & "-rel" + Else + $CurrentVersion = $CurrentVersion & "-dev" + EndIf + Return True +EndFunc + +; About Us +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/Notepad XS/MetroGUI-UDF/MetroGUI_UDF.au3 b/Notepad XS/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/Notepad XS/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/Notepad XS/MetroGUI-UDF/MetroThemes.au3 b/Notepad XS/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/Notepad XS/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/Notepad XS/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/Notepad XS/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/Notepad XS/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/Notepad XS/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/Notepad XS/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/Notepad XS/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/Notepad XS/MetroGUI-UDF/_GUIDisable.au3 b/Notepad XS/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/Notepad XS/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/Notepad XS/Notepad XS.au3 b/Notepad XS/Notepad XS.au3 new file mode 100755 index 0000000..20ca8e8 --- /dev/null +++ b/Notepad XS/Notepad XS.au3 @@ -0,0 +1,47 @@ + +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + +GetSoftDetails(@AutoItExe,"DEV") + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +#include +#include +#include +#Region ### START Koda GUI section ### Form= +Global $GUI = GUICreate("Form1", 557, 350, 506, 251) +Global $File = GUICtrlCreateMenu("Files") +Global $Edit = GUICtrlCreateMenu("Edit/Config") +Global $Com = GUICtrlCreateMenu("Commands") +Global $Com_Hide = GUICtrlCreateMenuItem("Hide",$Com) +Global $Note = GUICtrlCreateEdit("", 0, 0, 556, 328) +GUICtrlSetData($Note, "") +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + + EndSwitch +WEnd diff --git a/Notepad XS/Projet.kxf b/Notepad XS/Projet.kxf new file mode 100755 index 0000000..e8a2629 --- /dev/null +++ b/Notepad XS/Projet.kxf @@ -0,0 +1,229 @@ + + + + 192 + 154 + 633 + 292 + Form1 + clBtnFace + DEFAULT_CHARSET + clWindowText + -13 + Segoe UI + + Menu1 + False + True + -1798701056 + 256 + 1.04 + False + False + False + False + -1 + 1 + 0 + 1 + + 96 + 15 + + + + + 586 + 56 + 28 + 28 + Owner + MainMenu1 + + + + + + 5 + 9 + 70 + 23 + Utilisateur + DEFAULT_CHARSET + clWindowText + -16 + Segoe UI + + False + 0 + False + 1342308608 + 0 + + + + + + + 5 + 32 + 41 + 23 + Poste + DEFAULT_CHARSET + clWindowText + -16 + Segoe UI + + False + 1 + False + 1342308608 + 0 + + + + + + + 258 + 66 + 100 + 19 + Descriptif Rapide + 2 + False + 1342308609 + 0 + + + + + + + 81 + 7 + 418 + 23 + 3 + Input1 + 1342374016 + 512 + DockHeight + + + + + + 500 + 7 + 109 + 23 + 4 + Input1 + 1342374016 + 512 + DockHeight + + + + + + 50 + 32 + 294 + 23 + 5 + Input3 + 1342374016 + 512 + DockHeight + + + + + + 1 + 86 + 615 + 146 + + +
  • Edit1
  • +
    +
    + 6 + 1345523908 + 512 + +
    + +
    + + + 372 + 33 + 239 + 23 + 7 + Input3 + 1342374016 + 512 + DockHeight + + + + + + 346 + 34 + 25 + 23 + Tel. + DEFAULT_CHARSET + clWindowText + -16 + Segoe UI + + False + 8 + False + 1342308608 + 0 + + + + + + + + + + MenuItem2 + + + + + MenuItem4 + + + + + + + + MenuItem1 + + + + + MenuItem3 + + + + + + + +
    +
    \ No newline at end of file diff --git a/Notepad XS/README.md b/Notepad XS/README.md new file mode 100755 index 0000000..ce6d680 --- /dev/null +++ b/Notepad XS/README.md @@ -0,0 +1 @@ +Logiciel Tyleo Créé avec CNP \ No newline at end of file diff --git a/Notepad XS/Releases/.media b/Notepad XS/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/Notepad XS/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) + diff --git a/PATH Editor/PATH Adder.au3 b/PATH Editor/PATH Adder.au3 new file mode 100755 index 0000000..416f5bf --- /dev/null +++ b/PATH Editor/PATH Adder.au3 @@ -0,0 +1,62 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=PATHAdder.ico +#AutoIt3Wrapper_Res_Fileversion=1.0.0.1 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=PATHAdder +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +#include +#include +#include +#include +#Region ### START Koda GUI section ### Form= +Global $Form2 = GUICreate("User Path Adder", 409, 72, 275, 238) +GUICtrlSetFont(-1, 10, 400, 0, "Segoe UI") +Global $Loc = GUICtrlCreateInput("", 8, 8, 320, 24) +GUICtrlSetFont(-1,11,100, 0, "Consolas") +GUICtrlSetTip(-1,"Folder Location") +Global $Browse = GUICtrlCreateButton("📂", 376, 8, 25, 25) +GUICtrlSetFont(-1,14, 400, 0, "Segoe UI") +GUICtrlSetTip(-1,"Browse for Folder") +GUICtrlSetCursor(-1,0) +Global $Add = GUICtrlCreateButton("➕ Add This Folder to User Path (" & @UserName & ") ➕", 8, 40, 393, 25) +GUICtrlSetFont(-1,12, 400, 0, "Segoe UI") +GUICtrlSetTip(-1,"Add and Update Path Env") +GUICtrlSetCursor(-1,0) +Global $Paste = GUICtrlCreateButton("📫", 352, 8, 25, 25) +GUICtrlSetTip(-1,"Paste") +GUICtrlSetCursor(-1,0) +GUICtrlSetFont(-1,14, 400, 0, "Segoe UI") +Global $ClearUp = GUICtrlCreateButton("❌", 328, 8, 25, 25) +GUICtrlSetTip(-1,"Clear Up") +GUICtrlSetCursor(-1,0) +GUICtrlSetFont(-1,14, 400, 0, "Segoe UI") +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + Case $Paste + $KeyPaste = ClipGet() + GUICtrlSetData($Loc,$KeyPaste) + Case $ClearUp + GUICtrlSetData($Loc,"") + + Case $Browse + $FolderLoc = FileSelectFolder("Choose Folder",@MyDocumentsDir) + GUICtrlSetData($Loc,$FolderLoc) + + Case $Add + $PathAddDir = GUICtrlRead($Loc) + Run('setx path %path%;' & $PathAddDir) + EnvUpdate() + MsgBox(0,"Success","Variable Path Updated" & @CRLF & $PathAddDir) + + EndSwitch +WEnd diff --git a/PATH Editor/PATH Adder.exe b/PATH Editor/PATH Adder.exe new file mode 100755 index 0000000..97ad10a Binary files /dev/null and b/PATH Editor/PATH Adder.exe differ diff --git a/PATH Editor/PATHAdder.ico b/PATH Editor/PATHAdder.ico new file mode 100755 index 0000000..55fab8c Binary files /dev/null and b/PATH Editor/PATHAdder.ico differ diff --git a/Ping-GUI/MetroGUI-UDF/MetroGUI_UDF.au3 b/Ping-GUI/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/Ping-GUI/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/Ping-GUI/MetroGUI-UDF/MetroThemes.au3 b/Ping-GUI/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/Ping-GUI/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/Ping-GUI/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/Ping-GUI/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/Ping-GUI/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/Ping-GUI/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/Ping-GUI/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/Ping-GUI/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/Ping-GUI/MetroGUI-UDF/_GUIDisable.au3 b/Ping-GUI/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/Ping-GUI/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/Ping-GUI/Ping-GUI.au3 b/Ping-GUI/Ping-GUI.au3 new file mode 100755 index 0000000..aa7c211 --- /dev/null +++ b/Ping-GUI/Ping-GUI.au3 @@ -0,0 +1,23 @@ + +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "TyleoAboutMe.au3" + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + diff --git a/Ping-GUI/Releases/.media b/Ping-GUI/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/Ping-GUI/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) + diff --git a/Ping-GUI/TyleoAboutMe.au3 b/Ping-GUI/TyleoAboutMe.au3 new file mode 100755 index 0000000..75ff526 --- /dev/null +++ b/Ping-GUI/TyleoAboutMe.au3 @@ -0,0 +1,10 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/Project Maker/CNP.ico b/Project Maker/CNP.ico new file mode 100755 index 0000000..c5cb794 Binary files /dev/null and b/Project Maker/CNP.ico differ diff --git a/Project Maker/CreateNewProject.au3 b/Project Maker/CreateNewProject.au3 new file mode 100755 index 0000000..dac3304 --- /dev/null +++ b/Project Maker/CreateNewProject.au3 @@ -0,0 +1,70 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=CNP.ico +#AutoIt3Wrapper_Outfile=..\CNP_32.Exe +#AutoIt3Wrapper_Outfile_x64=..\CNP.Exe +#AutoIt3Wrapper_Compile_Both=y +#AutoIt3Wrapper_Res_Comment=Tyleo Project Creator +#AutoIt3Wrapper_Res_Description=Tyleo Project Creator +#AutoIt3Wrapper_Res_Fileversion=1.0.0.4 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=CNP +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. + +#include +#include +#include +#include +#include +#include +#Region ### START Koda GUI section ### Form= +Global $GUI = GUICreate("Tyleo Project Init", 375, 40, 432, 503) +Global $ProjName = GUICtrlCreateInput("", 8, 8, 281, 24) +GUICtrlSetFont(-1, 10, 400, 0, "Segoe UI") +Global $InitProject = GUICtrlCreateButton("CREATE", 296, 8, 73, 25) +GUICtrlSetFont(-1, 10, 400, 0, "Segoe UI") +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +if FileExists(@ScriptDir & "\_devtools") Then + ConsoleWrite("OK") +Else + DirCreate(@ScriptDir & "\_devtools") +EndIf + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + + Case $InitProject + $dName = GUICtrlRead($ProjName) + If $dName = "" Then + MsgBox(0+16,"Error","No Name entered. Nice try !") + Elseif FileExists(@ScriptDir & "\" & $dName) Then + MsgBox(0+16,"Error","This project already exist !") + Else + DirCreate(@ScriptDir & "\" & $dName) + DirCopy(@ScriptDir & "\_devtools",@ScriptDir & "\" & $dName,1) + FileMove(@ScriptDir & "\" & $dName & "\ProjectBase.au3",@ScriptDir & "\" & $dName & "\" & $dName & ".au3") + MsgBox(0,"Done","Project Folder created, Dev Tools copied." & @CRLF & @ScriptDir & "\" & $dName) + ShellExecute(@ScriptDir & "\" & $dName) + Exit(0) + EndIf + EndSwitch +WEnd diff --git a/Project Maker/Releases/CNP.Exe b/Project Maker/Releases/CNP.Exe new file mode 100755 index 0000000..4efe4fc Binary files /dev/null and b/Project Maker/Releases/CNP.Exe differ diff --git a/Project Maker/Releases/CNP_32.Exe b/Project Maker/Releases/CNP_32.Exe new file mode 100755 index 0000000..bcef022 Binary files /dev/null and b/Project Maker/Releases/CNP_32.Exe differ diff --git a/README.md b/README.md new file mode 100755 index 0000000..8011fa5 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +Zone de Développement Tyleo Softwares \ No newline at end of file diff --git a/SSH-VT/.filerun.versioning/Extensions.au3/4/data b/SSH-VT/.filerun.versioning/Extensions.au3/4/data new file mode 100755 index 0000000..197ee6a --- /dev/null +++ b/SSH-VT/.filerun.versioning/Extensions.au3/4/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647077155;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/.filerun.versioning/Extensions.au3/4/file b/SSH-VT/.filerun.versioning/Extensions.au3/4/file new file mode 100755 index 0000000..10fd066 --- /dev/null +++ b/SSH-VT/.filerun.versioning/Extensions.au3/4/file @@ -0,0 +1,34 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +; Color Accent +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +; Software Base Details +Func GetSoftDetails($Exe,$Stage) + Global $CurrentVersion,$CurrentName,$CurrentBaseVersion + $CurrentVersion = FileGetVersion($Exe,$FV_FILEVERSION) + $CurrentBaseVersion = FileGetVersion($Exe,$FV_PRODUCTVERSION) + $CurrentName = FileGetVersion($Exe,$FV_PRODUCTNAME) + if $Stage = "BETA" Then + $CurrentVersion = $CurrentVersion & "-beta" + Elseif $Stage = "RELEASE" or $Stage = "STABLE" Then + $CurrentVersion = $CurrentVersion & "-rel" + Else + $CurrentVersion = $CurrentVersion & "-dev" + EndIf + Return True +EndFunc + +; About Us +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2022" & @CRLF & " " & @CRLF & "MAKE IT HAPPENING" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/SSH-VT/.filerun.versioning/Extensions.au3/5/data b/SSH-VT/.filerun.versioning/Extensions.au3/5/data new file mode 100755 index 0000000..7b609a3 --- /dev/null +++ b/SSH-VT/.filerun.versioning/Extensions.au3/5/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647077237;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/.filerun.versioning/Extensions.au3/5/file b/SSH-VT/.filerun.versioning/Extensions.au3/5/file new file mode 100755 index 0000000..10fd066 --- /dev/null +++ b/SSH-VT/.filerun.versioning/Extensions.au3/5/file @@ -0,0 +1,34 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +; Color Accent +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +; Software Base Details +Func GetSoftDetails($Exe,$Stage) + Global $CurrentVersion,$CurrentName,$CurrentBaseVersion + $CurrentVersion = FileGetVersion($Exe,$FV_FILEVERSION) + $CurrentBaseVersion = FileGetVersion($Exe,$FV_PRODUCTVERSION) + $CurrentName = FileGetVersion($Exe,$FV_PRODUCTNAME) + if $Stage = "BETA" Then + $CurrentVersion = $CurrentVersion & "-beta" + Elseif $Stage = "RELEASE" or $Stage = "STABLE" Then + $CurrentVersion = $CurrentVersion & "-rel" + Else + $CurrentVersion = $CurrentVersion & "-dev" + EndIf + Return True +EndFunc + +; About Us +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2022" & @CRLF & " " & @CRLF & "MAKE IT HAPPENING" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/SSH-VT/.filerun.versioning/SSH-VT - MMode.au3/15/data b/SSH-VT/.filerun.versioning/SSH-VT - MMode.au3/15/data new file mode 100755 index 0000000..390f976 --- /dev/null +++ b/SSH-VT/.filerun.versioning/SSH-VT - MMode.au3/15/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647093694;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/.filerun.versioning/SSH-VT - MMode.au3/15/file b/SSH-VT/.filerun.versioning/SSH-VT - MMode.au3/15/file new file mode 100755 index 0000000..3bd0825 --- /dev/null +++ b/SSH-VT/.filerun.versioning/SSH-VT - MMode.au3/15/file @@ -0,0 +1,164 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=SSH_M.ico +#AutoIt3Wrapper_Outfile=Releases\SSHVT_Portable_x32.exe +#AutoIt3Wrapper_Outfile_x64=Releases\SSHVT_Portable_x64.exe +#AutoIt3Wrapper_Compile_Both=y +#AutoIt3Wrapper_Res_Comment=SSH-VirtualTerm (SSHVT) +#AutoIt3Wrapper_Res_Description=SSH-VirtualTerm (SSHVT) +#AutoIt3Wrapper_Res_Fileversion=1.2.0.6 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=SSH-VirtualTerm-Portable +#AutoIt3Wrapper_Res_ProductVersion=1.2.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + + +GetSoftDetails(@AutoItExe,"RELEASE") + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +$sshvt_config = @ScriptDir & "\sshvt_" & @UserName +if not FileExists($sshvt_config) Then + IniWrite($sshvt_config,"SSHVT","Profile Name","Default") + IniWrite($sshvt_config,"SSHVT","Private Key",@UserProfileDir & "\.ssh\id_rsa") + IniWrite($sshvt_config,"SSHVT","Host","localhost") + IniWrite($sshvt_config,"SSHVT","Port","22") + IniWrite($sshvt_config,"SSHVT","User",@UserName) +EndIf + +$sshvt_cfg_profile = IniRead($sshvt_config,"SSHVT","Profile Name","Default") +$sshvt_cfg_priv = IniRead($sshvt_config,"SSHVT","Private Key",@UserProfileDir & "\.ssh\id_rsa") +$sshvt_cfg_host = IniRead($sshvt_config,"SSHVT","Host","localhost") +$sshvt_cfg_port = IniRead($sshvt_config,"SSHVT","Port","22") +$sshvt_cfg_user = IniRead($sshvt_config,"SSHVT","User",@UserName) + +#include +#include +#include +#include +#include +#Region ### START Koda GUI section ### Form= +Global $Form1 = GUICreate("SecureSHell - " & $sshvt_cfg_profile, 522, 125, 276, 544) +GUISetFont("10","","","Segoe UI") +GUISetBkColor($CurrentAccent) +Global $Group1 = GUICtrlCreateGroup(" SecureShell Settings ", 0, 0, 521, 90) +Global $User = GUICtrlCreateInput($sshvt_cfg_user, 128, 20, 180, 21) +Global $Host = GUICtrlCreateInput($sshvt_cfg_host, 128, 43, 180, 21) +Global $Port = GUICtrlCreateInput($sshvt_cfg_port, 128, 66, 180, 21) +Global $Priv = GUICtrlCreateButton("PRIVKEY MODE", 320, 9, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $Pass = GUICtrlCreateButton("PASSWORD MODE", 320, 35, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $Cmd = GUICtrlCreateButton("OPEN CONSOLE", 320, 61, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $LUser = GUICtrlCreateLabel("USERNAME", 6, 20, 90, 17) +Global $LHost = GUICtrlCreateLabel("HOSTNAME", 6, 43, 90, 17) +Global $LPass = GUICtrlCreateLabel("PORT", 6, 66, 90, 17) +GUICtrlCreateGroup("", -99, -99, 1, 1) +Global $SoftLine = GUICtrlCreateLabel($CurrentName & " " & $CurrentVersion & " " & $CurrentBaseVersion, 1, 90, 519, 17) +Global $Menu = GUICtrlCreateMenu("Configuration") +Global $Menu_PrivKey = GUICtrlCreateMenuItem("Select Private Key" & @TAB & $sshvt_cfg_priv,$Menu) +Global $Menu_PrivKeyMenu = GUICtrlCreateMenu("Create a New Key",$Menu) +Global $Menu_PrivKeyGen_rsa2 = GUICtrlCreateMenuItem("RSA" & @TAB & "2048bits (normal)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa3 = GUICtrlCreateMenuItem("RSA" & @TAB & "3072bits (high)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa4 = GUICtrlCreateMenuItem("RSA" & @TAB & "4096bits (ultra)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa1 = GUICtrlCreateMenuItem("RSA" & @TAB & "1024bits (low)",$Menu_PrivKeyMenu) +GUICtrlCreateMenuItem("",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa1 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "256bits (low)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa2 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "384bits (medium)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa3 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "521bits (high)",$Menu_PrivKeyMenu) +GUICtrlCreateMenuItem("",$Menu) +Global $Menu_ReloadCfgNr = GUICtrlCreateMenuItem("Configuration Reload (N)" & @TAB & "NO WRITE / RELOAD ONLY",$Menu) +Global $Menu_ReloadCfgWr = GUICtrlCreateMenuItem("Configuration Reload (W)" & @TAB & "OVERWRITE / UPDATE",$Menu) +GUICtrlCreateMenuItem("",$Menu) +Global $Menu_ProfileRename = GUICtrlCreateMenuItem("Rename your Profile",$Menu) +Global $Menu_About = GUICtrlCreateMenu("About") +Global $Menu_About_D = GUICtrlCreateMenuItem("Devs",$Menu_About) +GUICtrlCreateMenuItem("",$Menu_About) +Global $Menu_About_T = GUICtrlCreateMenuItem("Website",$Menu_About) +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + Case $Menu_About_D + TyleoAbout($CurrentName) + Case $Menu_About_T + ShellExecute("https://tyleodev.fr") + Case $Menu_PrivKeyGen + Run("ssh-keygen") + Case $Menu_PrivKey + $KeySel = FileOpenDialog("Select Private Key",@UserProfileDir & "\.ssh","All (*)|KeyFile (*.key)|KeyFile ECDSA (*.ecdsa)",1) + $sshvt_cfg_priv = $KeySel + UpdateConfig() + + Case $Menu_ProfileRename + $NewName = InputBox("PROFILE RENAME " & $CurrentName,"New Name ?",$sshvt_cfg_profile,"","",125) + $sshvt_cfg_profile = $NewName + UpdateConfig() + + Case $Cmd + Run("cmd",@UserProfileDir) + + Case $Pass + UpdateConfigNoReload() + Run("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host) + + Case $Priv + UpdateConfigNoReload() + ConsoleWrite("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host & " -i" & " " & $sshvt_cfg_priv) + Run("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host & " -i" & " " & $sshvt_cfg_priv) + + Case $Menu_ReloadCfgNr + Reload() + + Case $Menu_ReloadCfgWr + UpdateConfig() + + EndSwitch +WEnd + +Func UpdateConfig() + IniWrite($sshvt_config,"SSHVT","Profile Name",$sshvt_cfg_profile) + IniWrite($sshvt_config,"SSHVT","Private Key",$sshvt_cfg_priv) + $sshvt_cfg_host = GUICtrlRead($Host) + IniWrite($sshvt_config,"SSHVT","Host",$sshvt_cfg_host) + $sshvt_cfg_port = GUICtrlRead($Port) + IniWrite($sshvt_config,"SSHVT","Port",$sshvt_cfg_port) + $sshvt_cfg_user = GUICtrlRead($User) + IniWrite($sshvt_config,"SSHVT","User",$sshvt_cfg_user) + Reload() +EndFunc + +Func UpdateConfigNoReload() + IniWrite($sshvt_config,"SSHVT","Profile Name",$sshvt_cfg_profile) + IniWrite($sshvt_config,"SSHVT","Private Key",$sshvt_cfg_priv) + $sshvt_cfg_host = GUICtrlRead($Host) + IniWrite($sshvt_config,"SSHVT","Host",$sshvt_cfg_host) + $sshvt_cfg_port = GUICtrlRead($Port) + IniWrite($sshvt_config,"SSHVT","Port",$sshvt_cfg_port) + $sshvt_cfg_user = GUICtrlRead($User) + IniWrite($sshvt_config,"SSHVT","User",$sshvt_cfg_user) + Return True +EndFunc + +Func Reload() + Run(@AutoItExe) + Exit(0) +EndFunc diff --git a/SSH-VT/.filerun.versioning/SSH-VT - MMode.au3/16/data b/SSH-VT/.filerun.versioning/SSH-VT - MMode.au3/16/data new file mode 100755 index 0000000..108ad96 --- /dev/null +++ b/SSH-VT/.filerun.versioning/SSH-VT - MMode.au3/16/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647194710;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/.filerun.versioning/SSH-VT - MMode.au3/16/file b/SSH-VT/.filerun.versioning/SSH-VT - MMode.au3/16/file new file mode 100755 index 0000000..a7ecaa6 --- /dev/null +++ b/SSH-VT/.filerun.versioning/SSH-VT - MMode.au3/16/file @@ -0,0 +1,176 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=SSH_M.ico +#AutoIt3Wrapper_Outfile=Releases\SSHVT_Portable_x32.exe +#AutoIt3Wrapper_Outfile_x64=Releases\SSHVT_Portable_x64.exe +#AutoIt3Wrapper_Compile_Both=y +#AutoIt3Wrapper_Res_Comment=SSH-VirtualTerm (SSHVT) +#AutoIt3Wrapper_Res_Description=SSH-VirtualTerm (SSHVT) +#AutoIt3Wrapper_Res_Fileversion=1.2.0.6 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=SSH-VirtualTerm-Portable +#AutoIt3Wrapper_Res_ProductVersion=1.2.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + + +GetSoftDetails(@AutoItExe,"RELEASE") + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +$sshvt_config = @ScriptDir & "\sshvt_" & @UserName +if not FileExists($sshvt_config) Then + IniWrite($sshvt_config,"SSHVT","Profile Name","Default") + IniWrite($sshvt_config,"SSHVT","Private Key",@UserProfileDir & "\.ssh\id_rsa") + IniWrite($sshvt_config,"SSHVT","Host","localhost") + IniWrite($sshvt_config,"SSHVT","Port","22") + IniWrite($sshvt_config,"SSHVT","User",@UserName) +EndIf + +$sshvt_cfg_profile = IniRead($sshvt_config,"SSHVT","Profile Name","Default") +$sshvt_cfg_priv = IniRead($sshvt_config,"SSHVT","Private Key",@UserProfileDir & "\.ssh\id_rsa") +$sshvt_cfg_host = IniRead($sshvt_config,"SSHVT","Host","localhost") +$sshvt_cfg_port = IniRead($sshvt_config,"SSHVT","Port","22") +$sshvt_cfg_user = IniRead($sshvt_config,"SSHVT","User",@UserName) + +#include +#include +#include +#include +#include +#Region ### START Koda GUI section ### Form= +Global $Form1 = GUICreate("SecureSHell - " & $sshvt_cfg_profile, 522, 125, 276, 544) +GUISetFont("10","","","Segoe UI") +GUISetBkColor($CurrentAccent) +Global $Group1 = GUICtrlCreateGroup(" SecureShell Settings ", 0, 0, 521, 90) +Global $User = GUICtrlCreateInput($sshvt_cfg_user, 128, 20, 180, 21) +Global $Host = GUICtrlCreateInput($sshvt_cfg_host, 128, 43, 180, 21) +Global $Port = GUICtrlCreateInput($sshvt_cfg_port, 128, 66, 180, 21) +Global $Priv = GUICtrlCreateButton("PRIVKEY MODE", 320, 9, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $Pass = GUICtrlCreateButton("PASSWORD MODE", 320, 35, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $Cmd = GUICtrlCreateButton("OPEN CONSOLE", 320, 61, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $LUser = GUICtrlCreateLabel("USERNAME", 6, 20, 90, 17) +Global $LHost = GUICtrlCreateLabel("HOSTNAME", 6, 43, 90, 17) +Global $LPass = GUICtrlCreateLabel("PORT", 6, 66, 90, 17) +GUICtrlCreateGroup("", -99, -99, 1, 1) +Global $SoftLine = GUICtrlCreateLabel($CurrentName & " " & $CurrentVersion & " " & $CurrentBaseVersion, 1, 90, 519, 17) +Global $Menu = GUICtrlCreateMenu("Configuration") +Global $Menu_PrivKey = GUICtrlCreateMenuItem("Select Private Key" & @TAB & $sshvt_cfg_priv,$Menu) +Global $Menu_PrivKeyMenu = GUICtrlCreateMenu("Create a New Key",$Menu) +Global $Menu_PrivKeyGen_rsa2 = GUICtrlCreateMenuItem("RSA" & @TAB & "2048bits (normal)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa3 = GUICtrlCreateMenuItem("RSA" & @TAB & "3072bits (high)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa4 = GUICtrlCreateMenuItem("RSA" & @TAB & "4096bits (ultra)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa1 = GUICtrlCreateMenuItem("RSA" & @TAB & "1024bits (low)",$Menu_PrivKeyMenu) +GUICtrlCreateMenuItem("",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa1 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "256bits (low)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa2 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "384bits (medium)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa3 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "521bits (high)",$Menu_PrivKeyMenu) +GUICtrlCreateMenuItem("",$Menu) +Global $Menu_ReloadCfgNr = GUICtrlCreateMenuItem("Configuration Reload (N)" & @TAB & "NO WRITE / RELOAD ONLY",$Menu) +Global $Menu_ReloadCfgWr = GUICtrlCreateMenuItem("Configuration Reload (W)" & @TAB & "OVERWRITE / UPDATE",$Menu) +GUICtrlCreateMenuItem("",$Menu) +Global $Menu_ProfileRename = GUICtrlCreateMenuItem("Rename your Profile",$Menu) +Global $Menu_About = GUICtrlCreateMenu("About") +Global $Menu_About_D = GUICtrlCreateMenuItem("Devs",$Menu_About) +GUICtrlCreateMenuItem("",$Menu_About) +Global $Menu_About_T = GUICtrlCreateMenuItem("Website",$Menu_About) +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + Case $Menu_About_D + TyleoAbout($CurrentName) + Case $Menu_About_T + ShellExecute("https://tyleodev.fr") + Case $Menu_PrivKeyGen_rsa2 + Run("ssh-keygen") + Case $Menu_PrivKeyGen_rsa3 + Run("ssh-keygen -b 3072") + Case $Menu_PrivKeyGen_rsa4 + Run("ssh-keygen -b 4096") + Case $Menu_PrivKeyGen_rsa1 + Run("ssh-keygen -b 1024") + Case $Menu_PrivKeyGen_ecdsa1 + Run("ssh-keygen -t ecdsa -b 256") + Case $Menu_PrivKeyGen_ecdsa2 + Run("ssh-keygen -t ecdsa -b 384") + Case $Menu_PrivKeyGen_ecdsa3 + Run("ssh-keygen -t ecdsa -b 521") + Case $Menu_PrivKey + $KeySel = FileOpenDialog("Select Private Key",@UserProfileDir & "\.ssh","All (*)|KeyFile (*.key)|KeyFile ECDSA (*.ecdsa)",1) + $sshvt_cfg_priv = $KeySel + UpdateConfig() + + Case $Menu_ProfileRename + $NewName = InputBox("PROFILE RENAME " & $CurrentName,"New Name ?",$sshvt_cfg_profile,"","",125) + $sshvt_cfg_profile = $NewName + UpdateConfig() + + Case $Cmd + Run("cmd",@UserProfileDir) + + Case $Pass + UpdateConfigNoReload() + Run("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host) + + Case $Priv + UpdateConfigNoReload() + ConsoleWrite("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host & " -i" & " " & $sshvt_cfg_priv) + Run("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host & " -i" & " " & $sshvt_cfg_priv) + + Case $Menu_ReloadCfgNr + Reload() + + Case $Menu_ReloadCfgWr + UpdateConfig() + + EndSwitch +WEnd + +Func UpdateConfig() + IniWrite($sshvt_config,"SSHVT","Profile Name",$sshvt_cfg_profile) + IniWrite($sshvt_config,"SSHVT","Private Key",$sshvt_cfg_priv) + $sshvt_cfg_host = GUICtrlRead($Host) + IniWrite($sshvt_config,"SSHVT","Host",$sshvt_cfg_host) + $sshvt_cfg_port = GUICtrlRead($Port) + IniWrite($sshvt_config,"SSHVT","Port",$sshvt_cfg_port) + $sshvt_cfg_user = GUICtrlRead($User) + IniWrite($sshvt_config,"SSHVT","User",$sshvt_cfg_user) + Reload() +EndFunc + +Func UpdateConfigNoReload() + IniWrite($sshvt_config,"SSHVT","Profile Name",$sshvt_cfg_profile) + IniWrite($sshvt_config,"SSHVT","Private Key",$sshvt_cfg_priv) + $sshvt_cfg_host = GUICtrlRead($Host) + IniWrite($sshvt_config,"SSHVT","Host",$sshvt_cfg_host) + $sshvt_cfg_port = GUICtrlRead($Port) + IniWrite($sshvt_config,"SSHVT","Port",$sshvt_cfg_port) + $sshvt_cfg_user = GUICtrlRead($User) + IniWrite($sshvt_config,"SSHVT","User",$sshvt_cfg_user) + Return True +EndFunc + +Func Reload() + Run(@AutoItExe) + Exit(0) +EndFunc diff --git a/SSH-VT/.filerun.versioning/SSH-VT - VMode.au3/16/data b/SSH-VT/.filerun.versioning/SSH-VT - VMode.au3/16/data new file mode 100755 index 0000000..ae8779d --- /dev/null +++ b/SSH-VT/.filerun.versioning/SSH-VT - VMode.au3/16/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647093688;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/.filerun.versioning/SSH-VT - VMode.au3/16/file b/SSH-VT/.filerun.versioning/SSH-VT - VMode.au3/16/file new file mode 100755 index 0000000..35ae6b2 --- /dev/null +++ b/SSH-VT/.filerun.versioning/SSH-VT - VMode.au3/16/file @@ -0,0 +1,164 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=SSH_V.ico +#AutoIt3Wrapper_Outfile=Releases\SSHVT_VDIMode_x32.exe +#AutoIt3Wrapper_Outfile_x64=Releases\SSHVT_VDIMode_x64.exe +#AutoIt3Wrapper_Compile_Both=y +#AutoIt3Wrapper_Res_Comment=SSH-VirtualTerm (SSHVT) +#AutoIt3Wrapper_Res_Description=SSH-VirtualTerm (SSHVT) +#AutoIt3Wrapper_Res_Fileversion=1.2.0.6 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=SSH-VirtualTerm-VDI +#AutoIt3Wrapper_Res_ProductVersion=1.2.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + + +GetSoftDetails(@AutoItExe,"RELEASE") + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +$sshvt_config = @AppDataDir & "\sshvt_" & @UserName +if not FileExists($sshvt_config) Then + IniWrite($sshvt_config,"SSHVT","Profile Name","Default") + IniWrite($sshvt_config,"SSHVT","Private Key",@UserProfileDir & "\.ssh\id_rsa") + IniWrite($sshvt_config,"SSHVT","Host","localhost") + IniWrite($sshvt_config,"SSHVT","Port","22") + IniWrite($sshvt_config,"SSHVT","User",@UserName) +EndIf + +$sshvt_cfg_profile = IniRead($sshvt_config,"SSHVT","Profile Name","Default") +$sshvt_cfg_priv = IniRead($sshvt_config,"SSHVT","Private Key",@UserProfileDir & "\.ssh\id_rsa") +$sshvt_cfg_host = IniRead($sshvt_config,"SSHVT","Host","localhost") +$sshvt_cfg_port = IniRead($sshvt_config,"SSHVT","Port","22") +$sshvt_cfg_user = IniRead($sshvt_config,"SSHVT","User",@UserName) + +#include +#include +#include +#include +#include +#Region ### START Koda GUI section ### Form= +Global $Form1 = GUICreate("SecureSHell - " & $sshvt_cfg_profile, 522, 125, 276, 544) +GUISetFont("10","","","Segoe UI") +GUISetBkColor($CurrentAccent) +Global $Group1 = GUICtrlCreateGroup(" SecureShell Settings ", 0, 0, 521, 90) +Global $User = GUICtrlCreateInput($sshvt_cfg_user, 128, 20, 180, 21) +Global $Host = GUICtrlCreateInput($sshvt_cfg_host, 128, 43, 180, 21) +Global $Port = GUICtrlCreateInput($sshvt_cfg_port, 128, 66, 180, 21) +Global $Priv = GUICtrlCreateButton("PRIVKEY MODE", 320, 9, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $Pass = GUICtrlCreateButton("PASSWORD MODE", 320, 35, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $Cmd = GUICtrlCreateButton("OPEN CONSOLE", 320, 61, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $LUser = GUICtrlCreateLabel("USERNAME", 6, 20, 90, 17) +Global $LHost = GUICtrlCreateLabel("HOSTNAME", 6, 43, 90, 17) +Global $LPass = GUICtrlCreateLabel("PORT", 6, 66, 90, 17) +GUICtrlCreateGroup("", -99, -99, 1, 1) +Global $SoftLine = GUICtrlCreateLabel($CurrentName & " " & $CurrentVersion & " " & $CurrentBaseVersion, 1, 90, 519, 17) +Global $Menu = GUICtrlCreateMenu("Configuration") +Global $Menu_PrivKey = GUICtrlCreateMenuItem("Select Private Key" & @TAB & $sshvt_cfg_priv,$Menu) +Global $Menu_PrivKeyMenu = GUICtrlCreateMenu("Create a New Key",$Menu) +Global $Menu_PrivKeyGen_rsa2 = GUICtrlCreateMenuItem("RSA" & @TAB & "2048bits (normal)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa3 = GUICtrlCreateMenuItem("RSA" & @TAB & "3072bits (high)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa4 = GUICtrlCreateMenuItem("RSA" & @TAB & "4096bits (ultra)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa1 = GUICtrlCreateMenuItem("RSA" & @TAB & "1024bits (low)",$Menu_PrivKeyMenu) +GUICtrlCreateMenuItem("",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa1 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "256bits (low)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa2 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "384bits (medium)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa3 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "521bits (high)",$Menu_PrivKeyMenu) +GUICtrlCreateMenuItem("",$Menu) +Global $Menu_ReloadCfgNr = GUICtrlCreateMenuItem("Configuration Reload (N)" & @TAB & "NO WRITE / RELOAD ONLY",$Menu) +Global $Menu_ReloadCfgWr = GUICtrlCreateMenuItem("Configuration Reload (W)" & @TAB & "OVERWRITE / UPDATE",$Menu) +GUICtrlCreateMenuItem("",$Menu) +Global $Menu_ProfileRename = GUICtrlCreateMenuItem("Rename your Profile",$Menu) +Global $Menu_About = GUICtrlCreateMenu("About") +Global $Menu_About_D = GUICtrlCreateMenuItem("Devs",$Menu_About) +GUICtrlCreateMenuItem("",$Menu_About) +Global $Menu_About_T = GUICtrlCreateMenuItem("Website",$Menu_About) +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + Case $Menu_About_D + TyleoAbout($CurrentName) + Case $Menu_About_T + ShellExecute("https://tyleodev.fr") + Case $Menu_PrivKeyGen + Run("ssh-keygen") + Case $Menu_PrivKey + $KeySel = FileOpenDialog("Select Private Key",@UserProfileDir & "\.ssh","All (*)|KeyFile (*.key)|KeyFile ECDSA (*.ecdsa)",1) + $sshvt_cfg_priv = $KeySel + UpdateConfig() + + Case $Menu_ProfileRename + $NewName = InputBox("PROFILE RENAME " & $CurrentName,"New Name ?",$sshvt_cfg_profile,"","",125) + $sshvt_cfg_profile = $NewName + UpdateConfig() + + Case $Cmd + Run("cmd",@UserProfileDir) + + Case $Pass + UpdateConfigNoReload() + Run("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host) + + Case $Priv + UpdateConfigNoReload() + ConsoleWrite("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host & " -i" & " " & $sshvt_cfg_priv) + Run("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host & " -i" & " " & $sshvt_cfg_priv) + + Case $Menu_ReloadCfgNr + Reload() + + Case $Menu_ReloadCfgWr + UpdateConfig() + + EndSwitch +WEnd + +Func UpdateConfig() + IniWrite($sshvt_config,"SSHVT","Profile Name",$sshvt_cfg_profile) + IniWrite($sshvt_config,"SSHVT","Private Key",$sshvt_cfg_priv) + $sshvt_cfg_host = GUICtrlRead($Host) + IniWrite($sshvt_config,"SSHVT","Host",$sshvt_cfg_host) + $sshvt_cfg_port = GUICtrlRead($Port) + IniWrite($sshvt_config,"SSHVT","Port",$sshvt_cfg_port) + $sshvt_cfg_user = GUICtrlRead($User) + IniWrite($sshvt_config,"SSHVT","User",$sshvt_cfg_user) + Reload() +EndFunc + +Func UpdateConfigNoReload() + IniWrite($sshvt_config,"SSHVT","Profile Name",$sshvt_cfg_profile) + IniWrite($sshvt_config,"SSHVT","Private Key",$sshvt_cfg_priv) + $sshvt_cfg_host = GUICtrlRead($Host) + IniWrite($sshvt_config,"SSHVT","Host",$sshvt_cfg_host) + $sshvt_cfg_port = GUICtrlRead($Port) + IniWrite($sshvt_config,"SSHVT","Port",$sshvt_cfg_port) + $sshvt_cfg_user = GUICtrlRead($User) + IniWrite($sshvt_config,"SSHVT","User",$sshvt_cfg_user) + Return True +EndFunc + +Func Reload() + Run(@AutoItExe) + Exit(0) +EndFunc diff --git a/SSH-VT/.filerun.versioning/SSH-VT - VMode.au3/17/data b/SSH-VT/.filerun.versioning/SSH-VT - VMode.au3/17/data new file mode 100755 index 0000000..880ffcf --- /dev/null +++ b/SSH-VT/.filerun.versioning/SSH-VT - VMode.au3/17/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647194708;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/.filerun.versioning/SSH-VT - VMode.au3/17/file b/SSH-VT/.filerun.versioning/SSH-VT - VMode.au3/17/file new file mode 100755 index 0000000..2fa9772 --- /dev/null +++ b/SSH-VT/.filerun.versioning/SSH-VT - VMode.au3/17/file @@ -0,0 +1,176 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=SSH_V.ico +#AutoIt3Wrapper_Outfile=Releases\SSHVT_VDIMode_x32.exe +#AutoIt3Wrapper_Outfile_x64=Releases\SSHVT_VDIMode_x64.exe +#AutoIt3Wrapper_Compile_Both=y +#AutoIt3Wrapper_Res_Comment=SSH-VirtualTerm (SSHVT) +#AutoIt3Wrapper_Res_Description=SSH-VirtualTerm (SSHVT) +#AutoIt3Wrapper_Res_Fileversion=1.2.0.6 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=SSH-VirtualTerm-VDI +#AutoIt3Wrapper_Res_ProductVersion=1.2.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + + +GetSoftDetails(@AutoItExe,"RELEASE") + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +$sshvt_config = @AppDataDir & "\sshvt_" & @UserName +if not FileExists($sshvt_config) Then + IniWrite($sshvt_config,"SSHVT","Profile Name","Default") + IniWrite($sshvt_config,"SSHVT","Private Key",@UserProfileDir & "\.ssh\id_rsa") + IniWrite($sshvt_config,"SSHVT","Host","localhost") + IniWrite($sshvt_config,"SSHVT","Port","22") + IniWrite($sshvt_config,"SSHVT","User",@UserName) +EndIf + +$sshvt_cfg_profile = IniRead($sshvt_config,"SSHVT","Profile Name","Default") +$sshvt_cfg_priv = IniRead($sshvt_config,"SSHVT","Private Key",@UserProfileDir & "\.ssh\id_rsa") +$sshvt_cfg_host = IniRead($sshvt_config,"SSHVT","Host","localhost") +$sshvt_cfg_port = IniRead($sshvt_config,"SSHVT","Port","22") +$sshvt_cfg_user = IniRead($sshvt_config,"SSHVT","User",@UserName) + +#include +#include +#include +#include +#include +#Region ### START Koda GUI section ### Form= +Global $Form1 = GUICreate("SecureSHell - " & $sshvt_cfg_profile, 522, 125, 276, 544) +GUISetFont("10","","","Segoe UI") +GUISetBkColor($CurrentAccent) +Global $Group1 = GUICtrlCreateGroup(" SecureShell Settings ", 0, 0, 521, 90) +Global $User = GUICtrlCreateInput($sshvt_cfg_user, 128, 20, 180, 21) +Global $Host = GUICtrlCreateInput($sshvt_cfg_host, 128, 43, 180, 21) +Global $Port = GUICtrlCreateInput($sshvt_cfg_port, 128, 66, 180, 21) +Global $Priv = GUICtrlCreateButton("PRIVKEY MODE", 320, 9, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $Pass = GUICtrlCreateButton("PASSWORD MODE", 320, 35, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $Cmd = GUICtrlCreateButton("OPEN CONSOLE", 320, 61, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $LUser = GUICtrlCreateLabel("USERNAME", 6, 20, 90, 17) +Global $LHost = GUICtrlCreateLabel("HOSTNAME", 6, 43, 90, 17) +Global $LPass = GUICtrlCreateLabel("PORT", 6, 66, 90, 17) +GUICtrlCreateGroup("", -99, -99, 1, 1) +Global $SoftLine = GUICtrlCreateLabel($CurrentName & " " & $CurrentVersion & " " & $CurrentBaseVersion, 1, 90, 519, 17) +Global $Menu = GUICtrlCreateMenu("Configuration") +Global $Menu_PrivKey = GUICtrlCreateMenuItem("Select Private Key" & @TAB & $sshvt_cfg_priv,$Menu) +Global $Menu_PrivKeyMenu = GUICtrlCreateMenu("Create a New Key",$Menu) +Global $Menu_PrivKeyGen_rsa2 = GUICtrlCreateMenuItem("RSA" & @TAB & "2048bits (normal)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa3 = GUICtrlCreateMenuItem("RSA" & @TAB & "3072bits (high)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa4 = GUICtrlCreateMenuItem("RSA" & @TAB & "4096bits (ultra)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa1 = GUICtrlCreateMenuItem("RSA" & @TAB & "1024bits (low)",$Menu_PrivKeyMenu) +GUICtrlCreateMenuItem("",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa1 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "256bits (low)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa2 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "384bits (medium)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa3 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "521bits (high)",$Menu_PrivKeyMenu) +GUICtrlCreateMenuItem("",$Menu) +Global $Menu_ReloadCfgNr = GUICtrlCreateMenuItem("Configuration Reload (N)" & @TAB & "NO WRITE / RELOAD ONLY",$Menu) +Global $Menu_ReloadCfgWr = GUICtrlCreateMenuItem("Configuration Reload (W)" & @TAB & "OVERWRITE / UPDATE",$Menu) +GUICtrlCreateMenuItem("",$Menu) +Global $Menu_ProfileRename = GUICtrlCreateMenuItem("Rename your Profile",$Menu) +Global $Menu_About = GUICtrlCreateMenu("About") +Global $Menu_About_D = GUICtrlCreateMenuItem("Devs",$Menu_About) +GUICtrlCreateMenuItem("",$Menu_About) +Global $Menu_About_T = GUICtrlCreateMenuItem("Website",$Menu_About) +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + Case $Menu_About_D + TyleoAbout($CurrentName) + Case $Menu_About_T + ShellExecute("https://tyleodev.fr") + Case $Menu_PrivKeyGen_rsa2 + Run("ssh-keygen") + Case $Menu_PrivKeyGen_rsa3 + Run("ssh-keygen -b 3072") + Case $Menu_PrivKeyGen_rsa4 + Run("ssh-keygen -b 4096") + Case $Menu_PrivKeyGen_rsa1 + Run("ssh-keygen -b 1024") + Case $Menu_PrivKeyGen_ecdsa1 + Run("ssh-keygen -t ecdsa -b 256") + Case $Menu_PrivKeyGen_ecdsa2 + Run("ssh-keygen -t ecdsa -b 384") + Case $Menu_PrivKeyGen_ecdsa3 + Run("ssh-keygen -t ecdsa -b 521") + Case $Menu_PrivKey + $KeySel = FileOpenDialog("Select Private Key",@UserProfileDir & "\.ssh","All (*)|KeyFile (*.key)|KeyFile ECDSA (*.ecdsa)",1) + $sshvt_cfg_priv = $KeySel + UpdateConfig() + + Case $Menu_ProfileRename + $NewName = InputBox("PROFILE RENAME " & $CurrentName,"New Name ?",$sshvt_cfg_profile,"","",125) + $sshvt_cfg_profile = $NewName + UpdateConfig() + + Case $Cmd + Run("cmd",@UserProfileDir) + + Case $Pass + UpdateConfigNoReload() + Run("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host) + + Case $Priv + UpdateConfigNoReload() + ConsoleWrite("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host & " -i" & " " & $sshvt_cfg_priv) + Run("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host & " -i" & " " & $sshvt_cfg_priv) + + Case $Menu_ReloadCfgNr + Reload() + + Case $Menu_ReloadCfgWr + UpdateConfig() + + EndSwitch +WEnd + +Func UpdateConfig() + IniWrite($sshvt_config,"SSHVT","Profile Name",$sshvt_cfg_profile) + IniWrite($sshvt_config,"SSHVT","Private Key",$sshvt_cfg_priv) + $sshvt_cfg_host = GUICtrlRead($Host) + IniWrite($sshvt_config,"SSHVT","Host",$sshvt_cfg_host) + $sshvt_cfg_port = GUICtrlRead($Port) + IniWrite($sshvt_config,"SSHVT","Port",$sshvt_cfg_port) + $sshvt_cfg_user = GUICtrlRead($User) + IniWrite($sshvt_config,"SSHVT","User",$sshvt_cfg_user) + Reload() +EndFunc + +Func UpdateConfigNoReload() + IniWrite($sshvt_config,"SSHVT","Profile Name",$sshvt_cfg_profile) + IniWrite($sshvt_config,"SSHVT","Private Key",$sshvt_cfg_priv) + $sshvt_cfg_host = GUICtrlRead($Host) + IniWrite($sshvt_config,"SSHVT","Host",$sshvt_cfg_host) + $sshvt_cfg_port = GUICtrlRead($Port) + IniWrite($sshvt_config,"SSHVT","Port",$sshvt_cfg_port) + $sshvt_cfg_user = GUICtrlRead($User) + IniWrite($sshvt_config,"SSHVT","User",$sshvt_cfg_user) + Return True +EndFunc + +Func Reload() + Run(@AutoItExe) + Exit(0) +EndFunc diff --git a/SSH-VT/.filerun.versioning/SSH-VT.au3/175/data b/SSH-VT/.filerun.versioning/SSH-VT.au3/175/data new file mode 100755 index 0000000..343e5d9 --- /dev/null +++ b/SSH-VT/.filerun.versioning/SSH-VT.au3/175/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647093633;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/.filerun.versioning/SSH-VT.au3/175/file b/SSH-VT/.filerun.versioning/SSH-VT.au3/175/file new file mode 100755 index 0000000..4f2b510 --- /dev/null +++ b/SSH-VT/.filerun.versioning/SSH-VT.au3/175/file @@ -0,0 +1,176 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=SSH.ico +#AutoIt3Wrapper_Outfile=Releases\SSHVT_x32.exe +#AutoIt3Wrapper_Outfile_x64=Releases\SSHVT_x64.exe +#AutoIt3Wrapper_Compile_Both=y +#AutoIt3Wrapper_Res_Comment=SSH-VirtualTerm (SSHVT) +#AutoIt3Wrapper_Res_Description=SSH-VirtualTerm (SSHVT) +#AutoIt3Wrapper_Res_Fileversion=1.2.0.5 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=SSH-VirtualTerm +#AutoIt3Wrapper_Res_ProductVersion=1.2.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + + +GetSoftDetails(@AutoItExe,"RELEASE") + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +$sshvt_config = @UserProfileDir & "\.ssh\sshvt_" & @UserName +if not FileExists($sshvt_config) Then + IniWrite($sshvt_config,"SSHVT","Profile Name","Default") + IniWrite($sshvt_config,"SSHVT","Private Key",@UserProfileDir & "\.ssh\id_rsa") + IniWrite($sshvt_config,"SSHVT","Host","localhost") + IniWrite($sshvt_config,"SSHVT","Port","22") + IniWrite($sshvt_config,"SSHVT","User",@UserName) +EndIf + +$sshvt_cfg_profile = IniRead($sshvt_config,"SSHVT","Profile Name","Default") +$sshvt_cfg_priv = IniRead($sshvt_config,"SSHVT","Private Key",@UserProfileDir & "\.ssh\id_rsa") +$sshvt_cfg_host = IniRead($sshvt_config,"SSHVT","Host","localhost") +$sshvt_cfg_port = IniRead($sshvt_config,"SSHVT","Port","22") +$sshvt_cfg_user = IniRead($sshvt_config,"SSHVT","User",@UserName) + +#include +#include +#include +#include +#include +#Region ### START Koda GUI section ### Form= +Global $Form1 = GUICreate("SecureSHell - " & $sshvt_cfg_profile, 522, 125, 276, 544) +GUISetFont("10","","","Segoe UI") +GUISetBkColor($CurrentAccent) +Global $Group1 = GUICtrlCreateGroup(" SecureShell Settings ", 0, 0, 521, 90) +Global $User = GUICtrlCreateInput($sshvt_cfg_user, 128, 20, 180, 21) +Global $Host = GUICtrlCreateInput($sshvt_cfg_host, 128, 43, 180, 21) +Global $Port = GUICtrlCreateInput($sshvt_cfg_port, 128, 66, 180, 21) +Global $Priv = GUICtrlCreateButton("PRIVKEY MODE", 320, 9, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $Pass = GUICtrlCreateButton("PASSWORD MODE", 320, 35, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $Cmd = GUICtrlCreateButton("OPEN CONSOLE", 320, 61, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $LUser = GUICtrlCreateLabel("USERNAME", 6, 20, 90, 17) +Global $LHost = GUICtrlCreateLabel("HOSTNAME", 6, 43, 90, 17) +Global $LPass = GUICtrlCreateLabel("PORT", 6, 66, 90, 17) +GUICtrlCreateGroup("", -99, -99, 1, 1) +Global $SoftLine = GUICtrlCreateLabel($CurrentName & " " & $CurrentVersion & " " & $CurrentBaseVersion, 1, 90, 519, 17) +Global $Menu = GUICtrlCreateMenu("Configuration") +Global $Menu_PrivKey = GUICtrlCreateMenuItem("Select Private Key" & @TAB & $sshvt_cfg_priv,$Menu) +Global $Menu_PrivKeyMenu = GUICtrlCreateMenu("Create a New Key",$Menu) +Global $Menu_PrivKeyGen_rsa2 = GUICtrlCreateMenuItem("RSA" & @TAB & "2048bits (normal)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa3 = GUICtrlCreateMenuItem("RSA" & @TAB & "3072bits (high)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa4 = GUICtrlCreateMenuItem("RSA" & @TAB & "4096bits (ultra)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa1 = GUICtrlCreateMenuItem("RSA" & @TAB & "1024bits (low)",$Menu_PrivKeyMenu) +GUICtrlCreateMenuItem("",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa1 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "256bits (low)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa2 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "384bits (medium)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa3 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "521bits (high)",$Menu_PrivKeyMenu) +GUICtrlCreateMenuItem("",$Menu) +Global $Menu_ReloadCfgNr = GUICtrlCreateMenuItem("Configuration Reload (N)" & @TAB & "NO WRITE / RELOAD ONLY",$Menu) +Global $Menu_ReloadCfgWr = GUICtrlCreateMenuItem("Configuration Reload (W)" & @TAB & "OVERWRITE / UPDATE",$Menu) +GUICtrlCreateMenuItem("",$Menu) +Global $Menu_ProfileRename = GUICtrlCreateMenuItem("Rename your Profile",$Menu) +Global $Menu_About = GUICtrlCreateMenu("About") +Global $Menu_About_D = GUICtrlCreateMenuItem("Devs",$Menu_About) +GUICtrlCreateMenuItem("",$Menu_About) +Global $Menu_About_T = GUICtrlCreateMenuItem("Website",$Menu_About) +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + Case $Menu_About_D + TyleoAbout($CurrentName) + Case $Menu_About_T + ShellExecute("https://tyleodev.fr") + Case $Menu_PrivKeyGen_rsa2 + Run("ssh-keygen") + Case $Menu_PrivKeyGen_rsa3 + Run("ssh-keygen -b 3072") + Case $Menu_PrivKeyGen_rsa4 + Run("ssh-keygen -b 4096") + Case $Menu_PrivKeyGen_rsa1 + Run("ssh-keygen -b 1024") + Case $Menu_PrivKeyGen_ecdsa1 + Run("ssh-keygen -t ecdsa -b 256") + Case $Menu_PrivKeyGen_ecdsa2 + Run("ssh-keygen -t ecdsa -b 384") + Case $Menu_PrivKeyGen_ecdsa3 + Run("ssh-keygen -t ecdsa -b 521") + Case $Menu_PrivKey + $KeySel = FileOpenDialog("Select Private Key",@UserProfileDir & "\.ssh","All (*)|KeyFile (*.key)|KeyFile ECDSA (*.ecdsa)",1) + $sshvt_cfg_priv = $KeySel + UpdateConfig() + + Case $Menu_ProfileRename + $NewName = InputBox("PROFILE RENAME " & $CurrentName,"New Name ?",$sshvt_cfg_profile,"","",125) + $sshvt_cfg_profile = $NewName + UpdateConfig() + + Case $Cmd + Run("cmd",@UserProfileDir) + + Case $Pass + UpdateConfigNoReload() + Run("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host) + + Case $Priv + UpdateConfigNoReload() + ConsoleWrite("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host & " -i" & " " & $sshvt_cfg_priv) + Run("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host & " -i" & " " & $sshvt_cfg_priv) + + Case $Menu_ReloadCfgNr + Reload() + + Case $Menu_ReloadCfgWr + UpdateConfig() + + EndSwitch +WEnd + +Func UpdateConfig() + IniWrite($sshvt_config,"SSHVT","Profile Name",$sshvt_cfg_profile) + IniWrite($sshvt_config,"SSHVT","Private Key",$sshvt_cfg_priv) + $sshvt_cfg_host = GUICtrlRead($Host) + IniWrite($sshvt_config,"SSHVT","Host",$sshvt_cfg_host) + $sshvt_cfg_port = GUICtrlRead($Port) + IniWrite($sshvt_config,"SSHVT","Port",$sshvt_cfg_port) + $sshvt_cfg_user = GUICtrlRead($User) + IniWrite($sshvt_config,"SSHVT","User",$sshvt_cfg_user) + Reload() +EndFunc + +Func UpdateConfigNoReload() + IniWrite($sshvt_config,"SSHVT","Profile Name",$sshvt_cfg_profile) + IniWrite($sshvt_config,"SSHVT","Private Key",$sshvt_cfg_priv) + $sshvt_cfg_host = GUICtrlRead($Host) + IniWrite($sshvt_config,"SSHVT","Host",$sshvt_cfg_host) + $sshvt_cfg_port = GUICtrlRead($Port) + IniWrite($sshvt_config,"SSHVT","Port",$sshvt_cfg_port) + $sshvt_cfg_user = GUICtrlRead($User) + IniWrite($sshvt_config,"SSHVT","User",$sshvt_cfg_user) + Return True +EndFunc + +Func Reload() + Run(@AutoItExe) + Exit(0) +EndFunc diff --git a/SSH-VT/.filerun.versioning/SSH-VT.au3/176/data b/SSH-VT/.filerun.versioning/SSH-VT.au3/176/data new file mode 100755 index 0000000..db1c882 --- /dev/null +++ b/SSH-VT/.filerun.versioning/SSH-VT.au3/176/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647194709;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/.filerun.versioning/SSH-VT.au3/176/file b/SSH-VT/.filerun.versioning/SSH-VT.au3/176/file new file mode 100755 index 0000000..4f2b510 --- /dev/null +++ b/SSH-VT/.filerun.versioning/SSH-VT.au3/176/file @@ -0,0 +1,176 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=SSH.ico +#AutoIt3Wrapper_Outfile=Releases\SSHVT_x32.exe +#AutoIt3Wrapper_Outfile_x64=Releases\SSHVT_x64.exe +#AutoIt3Wrapper_Compile_Both=y +#AutoIt3Wrapper_Res_Comment=SSH-VirtualTerm (SSHVT) +#AutoIt3Wrapper_Res_Description=SSH-VirtualTerm (SSHVT) +#AutoIt3Wrapper_Res_Fileversion=1.2.0.5 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=SSH-VirtualTerm +#AutoIt3Wrapper_Res_ProductVersion=1.2.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + + +GetSoftDetails(@AutoItExe,"RELEASE") + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +$sshvt_config = @UserProfileDir & "\.ssh\sshvt_" & @UserName +if not FileExists($sshvt_config) Then + IniWrite($sshvt_config,"SSHVT","Profile Name","Default") + IniWrite($sshvt_config,"SSHVT","Private Key",@UserProfileDir & "\.ssh\id_rsa") + IniWrite($sshvt_config,"SSHVT","Host","localhost") + IniWrite($sshvt_config,"SSHVT","Port","22") + IniWrite($sshvt_config,"SSHVT","User",@UserName) +EndIf + +$sshvt_cfg_profile = IniRead($sshvt_config,"SSHVT","Profile Name","Default") +$sshvt_cfg_priv = IniRead($sshvt_config,"SSHVT","Private Key",@UserProfileDir & "\.ssh\id_rsa") +$sshvt_cfg_host = IniRead($sshvt_config,"SSHVT","Host","localhost") +$sshvt_cfg_port = IniRead($sshvt_config,"SSHVT","Port","22") +$sshvt_cfg_user = IniRead($sshvt_config,"SSHVT","User",@UserName) + +#include +#include +#include +#include +#include +#Region ### START Koda GUI section ### Form= +Global $Form1 = GUICreate("SecureSHell - " & $sshvt_cfg_profile, 522, 125, 276, 544) +GUISetFont("10","","","Segoe UI") +GUISetBkColor($CurrentAccent) +Global $Group1 = GUICtrlCreateGroup(" SecureShell Settings ", 0, 0, 521, 90) +Global $User = GUICtrlCreateInput($sshvt_cfg_user, 128, 20, 180, 21) +Global $Host = GUICtrlCreateInput($sshvt_cfg_host, 128, 43, 180, 21) +Global $Port = GUICtrlCreateInput($sshvt_cfg_port, 128, 66, 180, 21) +Global $Priv = GUICtrlCreateButton("PRIVKEY MODE", 320, 9, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $Pass = GUICtrlCreateButton("PASSWORD MODE", 320, 35, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $Cmd = GUICtrlCreateButton("OPEN CONSOLE", 320, 61, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $LUser = GUICtrlCreateLabel("USERNAME", 6, 20, 90, 17) +Global $LHost = GUICtrlCreateLabel("HOSTNAME", 6, 43, 90, 17) +Global $LPass = GUICtrlCreateLabel("PORT", 6, 66, 90, 17) +GUICtrlCreateGroup("", -99, -99, 1, 1) +Global $SoftLine = GUICtrlCreateLabel($CurrentName & " " & $CurrentVersion & " " & $CurrentBaseVersion, 1, 90, 519, 17) +Global $Menu = GUICtrlCreateMenu("Configuration") +Global $Menu_PrivKey = GUICtrlCreateMenuItem("Select Private Key" & @TAB & $sshvt_cfg_priv,$Menu) +Global $Menu_PrivKeyMenu = GUICtrlCreateMenu("Create a New Key",$Menu) +Global $Menu_PrivKeyGen_rsa2 = GUICtrlCreateMenuItem("RSA" & @TAB & "2048bits (normal)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa3 = GUICtrlCreateMenuItem("RSA" & @TAB & "3072bits (high)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa4 = GUICtrlCreateMenuItem("RSA" & @TAB & "4096bits (ultra)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa1 = GUICtrlCreateMenuItem("RSA" & @TAB & "1024bits (low)",$Menu_PrivKeyMenu) +GUICtrlCreateMenuItem("",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa1 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "256bits (low)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa2 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "384bits (medium)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa3 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "521bits (high)",$Menu_PrivKeyMenu) +GUICtrlCreateMenuItem("",$Menu) +Global $Menu_ReloadCfgNr = GUICtrlCreateMenuItem("Configuration Reload (N)" & @TAB & "NO WRITE / RELOAD ONLY",$Menu) +Global $Menu_ReloadCfgWr = GUICtrlCreateMenuItem("Configuration Reload (W)" & @TAB & "OVERWRITE / UPDATE",$Menu) +GUICtrlCreateMenuItem("",$Menu) +Global $Menu_ProfileRename = GUICtrlCreateMenuItem("Rename your Profile",$Menu) +Global $Menu_About = GUICtrlCreateMenu("About") +Global $Menu_About_D = GUICtrlCreateMenuItem("Devs",$Menu_About) +GUICtrlCreateMenuItem("",$Menu_About) +Global $Menu_About_T = GUICtrlCreateMenuItem("Website",$Menu_About) +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + Case $Menu_About_D + TyleoAbout($CurrentName) + Case $Menu_About_T + ShellExecute("https://tyleodev.fr") + Case $Menu_PrivKeyGen_rsa2 + Run("ssh-keygen") + Case $Menu_PrivKeyGen_rsa3 + Run("ssh-keygen -b 3072") + Case $Menu_PrivKeyGen_rsa4 + Run("ssh-keygen -b 4096") + Case $Menu_PrivKeyGen_rsa1 + Run("ssh-keygen -b 1024") + Case $Menu_PrivKeyGen_ecdsa1 + Run("ssh-keygen -t ecdsa -b 256") + Case $Menu_PrivKeyGen_ecdsa2 + Run("ssh-keygen -t ecdsa -b 384") + Case $Menu_PrivKeyGen_ecdsa3 + Run("ssh-keygen -t ecdsa -b 521") + Case $Menu_PrivKey + $KeySel = FileOpenDialog("Select Private Key",@UserProfileDir & "\.ssh","All (*)|KeyFile (*.key)|KeyFile ECDSA (*.ecdsa)",1) + $sshvt_cfg_priv = $KeySel + UpdateConfig() + + Case $Menu_ProfileRename + $NewName = InputBox("PROFILE RENAME " & $CurrentName,"New Name ?",$sshvt_cfg_profile,"","",125) + $sshvt_cfg_profile = $NewName + UpdateConfig() + + Case $Cmd + Run("cmd",@UserProfileDir) + + Case $Pass + UpdateConfigNoReload() + Run("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host) + + Case $Priv + UpdateConfigNoReload() + ConsoleWrite("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host & " -i" & " " & $sshvt_cfg_priv) + Run("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host & " -i" & " " & $sshvt_cfg_priv) + + Case $Menu_ReloadCfgNr + Reload() + + Case $Menu_ReloadCfgWr + UpdateConfig() + + EndSwitch +WEnd + +Func UpdateConfig() + IniWrite($sshvt_config,"SSHVT","Profile Name",$sshvt_cfg_profile) + IniWrite($sshvt_config,"SSHVT","Private Key",$sshvt_cfg_priv) + $sshvt_cfg_host = GUICtrlRead($Host) + IniWrite($sshvt_config,"SSHVT","Host",$sshvt_cfg_host) + $sshvt_cfg_port = GUICtrlRead($Port) + IniWrite($sshvt_config,"SSHVT","Port",$sshvt_cfg_port) + $sshvt_cfg_user = GUICtrlRead($User) + IniWrite($sshvt_config,"SSHVT","User",$sshvt_cfg_user) + Reload() +EndFunc + +Func UpdateConfigNoReload() + IniWrite($sshvt_config,"SSHVT","Profile Name",$sshvt_cfg_profile) + IniWrite($sshvt_config,"SSHVT","Private Key",$sshvt_cfg_priv) + $sshvt_cfg_host = GUICtrlRead($Host) + IniWrite($sshvt_config,"SSHVT","Host",$sshvt_cfg_host) + $sshvt_cfg_port = GUICtrlRead($Port) + IniWrite($sshvt_config,"SSHVT","Port",$sshvt_cfg_port) + $sshvt_cfg_user = GUICtrlRead($User) + IniWrite($sshvt_config,"SSHVT","User",$sshvt_cfg_user) + Return True +EndFunc + +Func Reload() + Run(@AutoItExe) + Exit(0) +EndFunc diff --git a/SSH-VT/.filerun.versioning/SSH.ico/1/data b/SSH-VT/.filerun.versioning/SSH.ico/1/data new file mode 100755 index 0000000..5af5cd5 --- /dev/null +++ b/SSH-VT/.filerun.versioning/SSH.ico/1/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647076269;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/.filerun.versioning/SSH.ico/1/file b/SSH-VT/.filerun.versioning/SSH.ico/1/file new file mode 100755 index 0000000..31620ec Binary files /dev/null and b/SSH-VT/.filerun.versioning/SSH.ico/1/file differ diff --git a/SSH-VT/.filerun.versioning/SSH.png/1/data b/SSH-VT/.filerun.versioning/SSH.png/1/data new file mode 100755 index 0000000..5af5cd5 --- /dev/null +++ b/SSH-VT/.filerun.versioning/SSH.png/1/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647076269;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/.filerun.versioning/SSH.png/1/file b/SSH-VT/.filerun.versioning/SSH.png/1/file new file mode 100755 index 0000000..6a4c5ca Binary files /dev/null and b/SSH-VT/.filerun.versioning/SSH.png/1/file differ diff --git a/SSH-VT/Extensions.au3 b/SSH-VT/Extensions.au3 new file mode 100755 index 0000000..26d250b --- /dev/null +++ b/SSH-VT/Extensions.au3 @@ -0,0 +1,34 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +; Color Accent +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +; Software Base Details +Func GetSoftDetails($Exe,$Stage) + Global $CurrentVersion,$CurrentName,$CurrentBaseVersion + $CurrentVersion = FileGetVersion($Exe,$FV_FILEVERSION) + $CurrentBaseVersion = FileGetVersion($Exe,$FV_PRODUCTVERSION) + $CurrentName = FileGetVersion($Exe,$FV_PRODUCTNAME) + if $Stage = "BETA" Then + $CurrentVersion = $CurrentVersion & "-beta" + Elseif $Stage = "RELEASE" or $Stage = "STABLE" Then + $CurrentVersion = $CurrentVersion & "-rel" + Else + $CurrentVersion = $CurrentVersion & "-dev" + EndIf + Return True +EndFunc + +; About Us +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2022" & @CRLF & " " & @CRLF & "MAKE IT HAPPENING" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "support@tyleodev.fr",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/SSH-VT/Form1.kxf b/SSH-VT/Form1.kxf new file mode 100755 index 0000000..eb25fb5 --- /dev/null +++ b/SSH-VT/Form1.kxf @@ -0,0 +1,150 @@ + + + + 276 + 544 + 537 + 124 + Form1 + clBtnFace + DEFAULT_CHARSET + clWindowText + -11 + MS Sans Serif + + False + True + -1798701056 + 256 + 1.04 + False + False + False + False + -1 + 1 + 0 + 1 + + 96 + 13 + + + + + 0 + 0 + 521 + 65 + 1342308359 + 0 + Connexion + 0 + + + + + + 88 + 16 + 121 + 21 + 0 + 1342374016 + 512 + DockHeight + + + + + + 88 + 40 + 121 + 21 + 1 + 1342374016 + 512 + DockHeight + + + + + + 236 + 35 + 281 + 25 + Button1 + 2 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 236 + 9 + 281 + 25 + Button1 + 3 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 6 + 19 + 65 + 17 + HOSTNAME + 4 + False + 1342308608 + 0 + + + + + + + 6 + 42 + 34 + 17 + PORT + 5 + False + 1342308608 + 0 + + + + + + + + + 1 + 66 + 519 + 17 + Label3 + 1 + False + 1342308608 + 0 + + + + + + \ No newline at end of file diff --git a/SSH-VT/MetroGUI-UDF/MetroGUI_UDF.au3 b/SSH-VT/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/SSH-VT/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/SSH-VT/MetroGUI-UDF/MetroThemes.au3 b/SSH-VT/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/SSH-VT/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/SSH-VT/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/SSH-VT/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/SSH-VT/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/SSH-VT/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/SSH-VT/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/SSH-VT/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/SSH-VT/MetroGUI-UDF/_GUIDisable.au3 b/SSH-VT/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/SSH-VT/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/SSH-VT/Projet.kxf b/SSH-VT/Projet.kxf new file mode 100755 index 0000000..e8a2629 --- /dev/null +++ b/SSH-VT/Projet.kxf @@ -0,0 +1,229 @@ + + + + 192 + 154 + 633 + 292 + Form1 + clBtnFace + DEFAULT_CHARSET + clWindowText + -13 + Segoe UI + + Menu1 + False + True + -1798701056 + 256 + 1.04 + False + False + False + False + -1 + 1 + 0 + 1 + + 96 + 15 + + + + + 586 + 56 + 28 + 28 + Owner + MainMenu1 + + + + + + 5 + 9 + 70 + 23 + Utilisateur + DEFAULT_CHARSET + clWindowText + -16 + Segoe UI + + False + 0 + False + 1342308608 + 0 + + + + + + + 5 + 32 + 41 + 23 + Poste + DEFAULT_CHARSET + clWindowText + -16 + Segoe UI + + False + 1 + False + 1342308608 + 0 + + + + + + + 258 + 66 + 100 + 19 + Descriptif Rapide + 2 + False + 1342308609 + 0 + + + + + + + 81 + 7 + 418 + 23 + 3 + Input1 + 1342374016 + 512 + DockHeight + + + + + + 500 + 7 + 109 + 23 + 4 + Input1 + 1342374016 + 512 + DockHeight + + + + + + 50 + 32 + 294 + 23 + 5 + Input3 + 1342374016 + 512 + DockHeight + + + + + + 1 + 86 + 615 + 146 + + +
  • Edit1
  • +
    +
    + 6 + 1345523908 + 512 + +
    + +
    + + + 372 + 33 + 239 + 23 + 7 + Input3 + 1342374016 + 512 + DockHeight + + + + + + 346 + 34 + 25 + 23 + Tel. + DEFAULT_CHARSET + clWindowText + -16 + Segoe UI + + False + 8 + False + 1342308608 + 0 + + + + + + + + + + MenuItem2 + + + + + MenuItem4 + + + + + + + + MenuItem1 + + + + + MenuItem3 + + + + + + + +
    +
    \ No newline at end of file diff --git a/SSH-VT/README.md b/SSH-VT/README.md new file mode 100755 index 0000000..ce6d680 --- /dev/null +++ b/SSH-VT/README.md @@ -0,0 +1 @@ +Logiciel Tyleo Créé avec CNP \ No newline at end of file diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x32.exe/2/data b/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x32.exe/2/data new file mode 100755 index 0000000..d21370e --- /dev/null +++ b/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x32.exe/2/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647077503;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x32.exe/2/file b/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x32.exe/2/file new file mode 100755 index 0000000..d7e4456 Binary files /dev/null and b/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x32.exe/2/file differ diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x32.exe/3/data b/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x32.exe/3/data new file mode 100755 index 0000000..108ad96 --- /dev/null +++ b/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x32.exe/3/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647194710;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x32.exe/3/file b/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x32.exe/3/file new file mode 100755 index 0000000..4282d9c Binary files /dev/null and b/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x32.exe/3/file differ diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x64.exe/2/data b/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x64.exe/2/data new file mode 100755 index 0000000..993f37d --- /dev/null +++ b/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x64.exe/2/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647077520;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x64.exe/2/file b/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x64.exe/2/file new file mode 100755 index 0000000..b3cfa99 Binary files /dev/null and b/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x64.exe/2/file differ diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x64.exe/3/data b/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x64.exe/3/data new file mode 100755 index 0000000..b8710d7 --- /dev/null +++ b/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x64.exe/3/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647093819;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x64.exe/3/file b/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x64.exe/3/file new file mode 100755 index 0000000..29b58d6 Binary files /dev/null and b/SSH-VT/Releases/.filerun.versioning/SSHVT_Portable_x64.exe/3/file differ diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x32.exe/2/data b/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x32.exe/2/data new file mode 100755 index 0000000..214b292 --- /dev/null +++ b/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x32.exe/2/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647077505;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x32.exe/2/file b/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x32.exe/2/file new file mode 100755 index 0000000..4753884 Binary files /dev/null and b/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x32.exe/2/file differ diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x32.exe/3/data b/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x32.exe/3/data new file mode 100755 index 0000000..2e2d23a --- /dev/null +++ b/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x32.exe/3/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647093788;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x32.exe/3/file b/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x32.exe/3/file new file mode 100755 index 0000000..b9adfcd Binary files /dev/null and b/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x32.exe/3/file differ diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x64.exe/2/data b/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x64.exe/2/data new file mode 100755 index 0000000..706160c --- /dev/null +++ b/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x64.exe/2/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647077519;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x64.exe/2/file b/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x64.exe/2/file new file mode 100755 index 0000000..4cca0ae Binary files /dev/null and b/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x64.exe/2/file differ diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x64.exe/3/data b/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x64.exe/3/data new file mode 100755 index 0000000..bcd38f7 --- /dev/null +++ b/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x64.exe/3/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647194706;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x64.exe/3/file b/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x64.exe/3/file new file mode 100755 index 0000000..2150406 Binary files /dev/null and b/SSH-VT/Releases/.filerun.versioning/SSHVT_VDIMode_x64.exe/3/file differ diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_x32.exe/6/data b/SSH-VT/Releases/.filerun.versioning/SSHVT_x32.exe/6/data new file mode 100755 index 0000000..2db1646 --- /dev/null +++ b/SSH-VT/Releases/.filerun.versioning/SSHVT_x32.exe/6/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647077527;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_x32.exe/6/file b/SSH-VT/Releases/.filerun.versioning/SSHVT_x32.exe/6/file new file mode 100755 index 0000000..080f444 Binary files /dev/null and b/SSH-VT/Releases/.filerun.versioning/SSHVT_x32.exe/6/file differ diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_x32.exe/7/data b/SSH-VT/Releases/.filerun.versioning/SSHVT_x32.exe/7/data new file mode 100755 index 0000000..d5b9fe1 --- /dev/null +++ b/SSH-VT/Releases/.filerun.versioning/SSHVT_x32.exe/7/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647194663;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_x32.exe/7/file b/SSH-VT/Releases/.filerun.versioning/SSHVT_x32.exe/7/file new file mode 100755 index 0000000..0f8e802 Binary files /dev/null and b/SSH-VT/Releases/.filerun.versioning/SSHVT_x32.exe/7/file differ diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_x64.exe/7/data b/SSH-VT/Releases/.filerun.versioning/SSHVT_x64.exe/7/data new file mode 100755 index 0000000..45667f6 --- /dev/null +++ b/SSH-VT/Releases/.filerun.versioning/SSHVT_x64.exe/7/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647077524;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_x64.exe/7/file b/SSH-VT/Releases/.filerun.versioning/SSHVT_x64.exe/7/file new file mode 100755 index 0000000..b838066 Binary files /dev/null and b/SSH-VT/Releases/.filerun.versioning/SSHVT_x64.exe/7/file differ diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_x64.exe/8/data b/SSH-VT/Releases/.filerun.versioning/SSHVT_x64.exe/8/data new file mode 100755 index 0000000..569a018 --- /dev/null +++ b/SSH-VT/Releases/.filerun.versioning/SSHVT_x64.exe/8/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647194727;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/SSH-VT/Releases/.filerun.versioning/SSHVT_x64.exe/8/file b/SSH-VT/Releases/.filerun.versioning/SSHVT_x64.exe/8/file new file mode 100755 index 0000000..4a0de9f Binary files /dev/null and b/SSH-VT/Releases/.filerun.versioning/SSHVT_x64.exe/8/file differ diff --git a/SSH-VT/Releases/SSHVT_Portable_x32.exe b/SSH-VT/Releases/SSHVT_Portable_x32.exe new file mode 100755 index 0000000..ac3c440 Binary files /dev/null and b/SSH-VT/Releases/SSHVT_Portable_x32.exe differ diff --git a/SSH-VT/Releases/SSHVT_Portable_x64.exe b/SSH-VT/Releases/SSHVT_Portable_x64.exe new file mode 100755 index 0000000..9c3be9e Binary files /dev/null and b/SSH-VT/Releases/SSHVT_Portable_x64.exe differ diff --git a/SSH-VT/Releases/SSHVT_VDIMode_x32.exe b/SSH-VT/Releases/SSHVT_VDIMode_x32.exe new file mode 100755 index 0000000..1ecced8 Binary files /dev/null and b/SSH-VT/Releases/SSHVT_VDIMode_x32.exe differ diff --git a/SSH-VT/Releases/SSHVT_VDIMode_x64.exe b/SSH-VT/Releases/SSHVT_VDIMode_x64.exe new file mode 100755 index 0000000..c921d10 Binary files /dev/null and b/SSH-VT/Releases/SSHVT_VDIMode_x64.exe differ diff --git a/SSH-VT/Releases/SSHVT_x32.exe b/SSH-VT/Releases/SSHVT_x32.exe new file mode 100755 index 0000000..020f6bf Binary files /dev/null and b/SSH-VT/Releases/SSHVT_x32.exe differ diff --git a/SSH-VT/Releases/SSHVT_x64.exe b/SSH-VT/Releases/SSHVT_x64.exe new file mode 100755 index 0000000..74f8f72 Binary files /dev/null and b/SSH-VT/Releases/SSHVT_x64.exe differ diff --git a/SSH-VT/SSH-VT - MMode.au3 b/SSH-VT/SSH-VT - MMode.au3 new file mode 100755 index 0000000..4fc2a32 --- /dev/null +++ b/SSH-VT/SSH-VT - MMode.au3 @@ -0,0 +1,176 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=SSH_M.ico +#AutoIt3Wrapper_Outfile=Releases\SSHVT_Portable_x32.exe +#AutoIt3Wrapper_Outfile_x64=Releases\SSHVT_Portable_x64.exe +#AutoIt3Wrapper_Compile_Both=y +#AutoIt3Wrapper_Res_Comment=SSH-VirtualTerm (SSHVT) +#AutoIt3Wrapper_Res_Description=SSH-VirtualTerm (SSHVT) +#AutoIt3Wrapper_Res_Fileversion=1.2.0.7 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=SSH-VirtualTerm-Portable +#AutoIt3Wrapper_Res_ProductVersion=1.2.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + + +GetSoftDetails(@AutoItExe,"RELEASE") + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +$sshvt_config = @ScriptDir & "\sshvt_" & @UserName +if not FileExists($sshvt_config) Then + IniWrite($sshvt_config,"SSHVT","Profile Name","Default") + IniWrite($sshvt_config,"SSHVT","Private Key",@UserProfileDir & "\.ssh\id_rsa") + IniWrite($sshvt_config,"SSHVT","Host","localhost") + IniWrite($sshvt_config,"SSHVT","Port","22") + IniWrite($sshvt_config,"SSHVT","User",@UserName) +EndIf + +$sshvt_cfg_profile = IniRead($sshvt_config,"SSHVT","Profile Name","Default") +$sshvt_cfg_priv = IniRead($sshvt_config,"SSHVT","Private Key",@UserProfileDir & "\.ssh\id_rsa") +$sshvt_cfg_host = IniRead($sshvt_config,"SSHVT","Host","localhost") +$sshvt_cfg_port = IniRead($sshvt_config,"SSHVT","Port","22") +$sshvt_cfg_user = IniRead($sshvt_config,"SSHVT","User",@UserName) + +#include +#include +#include +#include +#include +#Region ### START Koda GUI section ### Form= +Global $Form1 = GUICreate("SecureSHell - " & $sshvt_cfg_profile, 522, 125, 276, 544) +GUISetFont("10","","","Segoe UI") +GUISetBkColor($CurrentAccent) +Global $Group1 = GUICtrlCreateGroup(" SecureShell Settings ", 0, 0, 521, 90) +Global $User = GUICtrlCreateInput($sshvt_cfg_user, 128, 20, 180, 21) +Global $Host = GUICtrlCreateInput($sshvt_cfg_host, 128, 43, 180, 21) +Global $Port = GUICtrlCreateInput($sshvt_cfg_port, 128, 66, 180, 21) +Global $Priv = GUICtrlCreateButton("PRIVKEY MODE", 320, 9, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $Pass = GUICtrlCreateButton("PASSWORD MODE", 320, 35, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $Cmd = GUICtrlCreateButton("OPEN CONSOLE", 320, 61, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $LUser = GUICtrlCreateLabel("USERNAME", 6, 20, 90, 17) +Global $LHost = GUICtrlCreateLabel("HOSTNAME", 6, 43, 90, 17) +Global $LPass = GUICtrlCreateLabel("PORT", 6, 66, 90, 17) +GUICtrlCreateGroup("", -99, -99, 1, 1) +Global $SoftLine = GUICtrlCreateLabel($CurrentName & " " & $CurrentVersion & " " & $CurrentBaseVersion, 1, 90, 519, 17) +Global $Menu = GUICtrlCreateMenu("Configuration") +Global $Menu_PrivKey = GUICtrlCreateMenuItem("Select Private Key" & @TAB & $sshvt_cfg_priv,$Menu) +Global $Menu_PrivKeyMenu = GUICtrlCreateMenu("Create a New Key",$Menu) +Global $Menu_PrivKeyGen_rsa2 = GUICtrlCreateMenuItem("RSA" & @TAB & "2048bits (normal)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa3 = GUICtrlCreateMenuItem("RSA" & @TAB & "3072bits (high)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa4 = GUICtrlCreateMenuItem("RSA" & @TAB & "4096bits (ultra)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa1 = GUICtrlCreateMenuItem("RSA" & @TAB & "1024bits (low)",$Menu_PrivKeyMenu) +GUICtrlCreateMenuItem("",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa1 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "256bits (low)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa2 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "384bits (medium)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa3 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "521bits (high)",$Menu_PrivKeyMenu) +GUICtrlCreateMenuItem("",$Menu) +Global $Menu_ReloadCfgNr = GUICtrlCreateMenuItem("Configuration Reload (N)" & @TAB & "NO WRITE / RELOAD ONLY",$Menu) +Global $Menu_ReloadCfgWr = GUICtrlCreateMenuItem("Configuration Reload (W)" & @TAB & "OVERWRITE / UPDATE",$Menu) +GUICtrlCreateMenuItem("",$Menu) +Global $Menu_ProfileRename = GUICtrlCreateMenuItem("Rename your Profile",$Menu) +Global $Menu_About = GUICtrlCreateMenu("About") +Global $Menu_About_D = GUICtrlCreateMenuItem("Devs",$Menu_About) +GUICtrlCreateMenuItem("",$Menu_About) +Global $Menu_About_T = GUICtrlCreateMenuItem("Website",$Menu_About) +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + Case $Menu_About_D + TyleoAbout($CurrentName) + Case $Menu_About_T + ShellExecute("https://tyleodev.fr") + Case $Menu_PrivKeyGen_rsa2 + Run("ssh-keygen") + Case $Menu_PrivKeyGen_rsa3 + Run("ssh-keygen -b 3072") + Case $Menu_PrivKeyGen_rsa4 + Run("ssh-keygen -b 4096") + Case $Menu_PrivKeyGen_rsa1 + Run("ssh-keygen -b 1024") + Case $Menu_PrivKeyGen_ecdsa1 + Run("ssh-keygen -t ecdsa -b 256") + Case $Menu_PrivKeyGen_ecdsa2 + Run("ssh-keygen -t ecdsa -b 384") + Case $Menu_PrivKeyGen_ecdsa3 + Run("ssh-keygen -t ecdsa -b 521") + Case $Menu_PrivKey + $KeySel = FileOpenDialog("Select Private Key",@UserProfileDir & "\.ssh","All (*)|KeyFile (*.key)|KeyFile ECDSA (*.ecdsa)",1) + $sshvt_cfg_priv = $KeySel + UpdateConfig() + + Case $Menu_ProfileRename + $NewName = InputBox("PROFILE RENAME " & $CurrentName,"New Name ?",$sshvt_cfg_profile,"","",125) + $sshvt_cfg_profile = $NewName + UpdateConfig() + + Case $Cmd + Run("cmd",@UserProfileDir) + + Case $Pass + UpdateConfigNoReload() + Run("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host) + + Case $Priv + UpdateConfigNoReload() + ConsoleWrite("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host & " -i" & " " & $sshvt_cfg_priv) + Run("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host & " -i" & " " & $sshvt_cfg_priv) + + Case $Menu_ReloadCfgNr + Reload() + + Case $Menu_ReloadCfgWr + UpdateConfig() + + EndSwitch +WEnd + +Func UpdateConfig() + IniWrite($sshvt_config,"SSHVT","Profile Name",$sshvt_cfg_profile) + IniWrite($sshvt_config,"SSHVT","Private Key",$sshvt_cfg_priv) + $sshvt_cfg_host = GUICtrlRead($Host) + IniWrite($sshvt_config,"SSHVT","Host",$sshvt_cfg_host) + $sshvt_cfg_port = GUICtrlRead($Port) + IniWrite($sshvt_config,"SSHVT","Port",$sshvt_cfg_port) + $sshvt_cfg_user = GUICtrlRead($User) + IniWrite($sshvt_config,"SSHVT","User",$sshvt_cfg_user) + Reload() +EndFunc + +Func UpdateConfigNoReload() + IniWrite($sshvt_config,"SSHVT","Profile Name",$sshvt_cfg_profile) + IniWrite($sshvt_config,"SSHVT","Private Key",$sshvt_cfg_priv) + $sshvt_cfg_host = GUICtrlRead($Host) + IniWrite($sshvt_config,"SSHVT","Host",$sshvt_cfg_host) + $sshvt_cfg_port = GUICtrlRead($Port) + IniWrite($sshvt_config,"SSHVT","Port",$sshvt_cfg_port) + $sshvt_cfg_user = GUICtrlRead($User) + IniWrite($sshvt_config,"SSHVT","User",$sshvt_cfg_user) + Return True +EndFunc + +Func Reload() + Run(@AutoItExe) + Exit(0) +EndFunc diff --git a/SSH-VT/SSH-VT - VMode.au3 b/SSH-VT/SSH-VT - VMode.au3 new file mode 100755 index 0000000..58b053b --- /dev/null +++ b/SSH-VT/SSH-VT - VMode.au3 @@ -0,0 +1,176 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=SSH_V.ico +#AutoIt3Wrapper_Outfile=Releases\SSHVT_VDIMode_x32.exe +#AutoIt3Wrapper_Outfile_x64=Releases\SSHVT_VDIMode_x64.exe +#AutoIt3Wrapper_Compile_Both=y +#AutoIt3Wrapper_Res_Comment=SSH-VirtualTerm (SSHVT) +#AutoIt3Wrapper_Res_Description=SSH-VirtualTerm (SSHVT) +#AutoIt3Wrapper_Res_Fileversion=1.2.0.7 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=SSH-VirtualTerm-VDI +#AutoIt3Wrapper_Res_ProductVersion=1.2.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + + +GetSoftDetails(@AutoItExe,"RELEASE") + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +$sshvt_config = @AppDataDir & "\sshvt_" & @UserName +if not FileExists($sshvt_config) Then + IniWrite($sshvt_config,"SSHVT","Profile Name","Default") + IniWrite($sshvt_config,"SSHVT","Private Key",@UserProfileDir & "\.ssh\id_rsa") + IniWrite($sshvt_config,"SSHVT","Host","localhost") + IniWrite($sshvt_config,"SSHVT","Port","22") + IniWrite($sshvt_config,"SSHVT","User",@UserName) +EndIf + +$sshvt_cfg_profile = IniRead($sshvt_config,"SSHVT","Profile Name","Default") +$sshvt_cfg_priv = IniRead($sshvt_config,"SSHVT","Private Key",@UserProfileDir & "\.ssh\id_rsa") +$sshvt_cfg_host = IniRead($sshvt_config,"SSHVT","Host","localhost") +$sshvt_cfg_port = IniRead($sshvt_config,"SSHVT","Port","22") +$sshvt_cfg_user = IniRead($sshvt_config,"SSHVT","User",@UserName) + +#include +#include +#include +#include +#include +#Region ### START Koda GUI section ### Form= +Global $Form1 = GUICreate("SecureSHell - " & $sshvt_cfg_profile, 522, 125, 276, 544) +GUISetFont("10","","","Segoe UI") +GUISetBkColor($CurrentAccent) +Global $Group1 = GUICtrlCreateGroup(" SecureShell Settings ", 0, 0, 521, 90) +Global $User = GUICtrlCreateInput($sshvt_cfg_user, 128, 20, 180, 21) +Global $Host = GUICtrlCreateInput($sshvt_cfg_host, 128, 43, 180, 21) +Global $Port = GUICtrlCreateInput($sshvt_cfg_port, 128, 66, 180, 21) +Global $Priv = GUICtrlCreateButton("PRIVKEY MODE", 320, 9, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $Pass = GUICtrlCreateButton("PASSWORD MODE", 320, 35, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $Cmd = GUICtrlCreateButton("OPEN CONSOLE", 320, 61, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $LUser = GUICtrlCreateLabel("USERNAME", 6, 20, 90, 17) +Global $LHost = GUICtrlCreateLabel("HOSTNAME", 6, 43, 90, 17) +Global $LPass = GUICtrlCreateLabel("PORT", 6, 66, 90, 17) +GUICtrlCreateGroup("", -99, -99, 1, 1) +Global $SoftLine = GUICtrlCreateLabel($CurrentName & " " & $CurrentVersion & " " & $CurrentBaseVersion, 1, 90, 519, 17) +Global $Menu = GUICtrlCreateMenu("Configuration") +Global $Menu_PrivKey = GUICtrlCreateMenuItem("Select Private Key" & @TAB & $sshvt_cfg_priv,$Menu) +Global $Menu_PrivKeyMenu = GUICtrlCreateMenu("Create a New Key",$Menu) +Global $Menu_PrivKeyGen_rsa2 = GUICtrlCreateMenuItem("RSA" & @TAB & "2048bits (normal)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa3 = GUICtrlCreateMenuItem("RSA" & @TAB & "3072bits (high)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa4 = GUICtrlCreateMenuItem("RSA" & @TAB & "4096bits (ultra)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa1 = GUICtrlCreateMenuItem("RSA" & @TAB & "1024bits (low)",$Menu_PrivKeyMenu) +GUICtrlCreateMenuItem("",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa1 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "256bits (low)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa2 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "384bits (medium)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa3 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "521bits (high)",$Menu_PrivKeyMenu) +GUICtrlCreateMenuItem("",$Menu) +Global $Menu_ReloadCfgNr = GUICtrlCreateMenuItem("Configuration Reload (N)" & @TAB & "NO WRITE / RELOAD ONLY",$Menu) +Global $Menu_ReloadCfgWr = GUICtrlCreateMenuItem("Configuration Reload (W)" & @TAB & "OVERWRITE / UPDATE",$Menu) +GUICtrlCreateMenuItem("",$Menu) +Global $Menu_ProfileRename = GUICtrlCreateMenuItem("Rename your Profile",$Menu) +Global $Menu_About = GUICtrlCreateMenu("About") +Global $Menu_About_D = GUICtrlCreateMenuItem("Devs",$Menu_About) +GUICtrlCreateMenuItem("",$Menu_About) +Global $Menu_About_T = GUICtrlCreateMenuItem("Website",$Menu_About) +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + Case $Menu_About_D + TyleoAbout($CurrentName) + Case $Menu_About_T + ShellExecute("https://tyleodev.fr") + Case $Menu_PrivKeyGen_rsa2 + Run("ssh-keygen") + Case $Menu_PrivKeyGen_rsa3 + Run("ssh-keygen -b 3072") + Case $Menu_PrivKeyGen_rsa4 + Run("ssh-keygen -b 4096") + Case $Menu_PrivKeyGen_rsa1 + Run("ssh-keygen -b 1024") + Case $Menu_PrivKeyGen_ecdsa1 + Run("ssh-keygen -t ecdsa -b 256") + Case $Menu_PrivKeyGen_ecdsa2 + Run("ssh-keygen -t ecdsa -b 384") + Case $Menu_PrivKeyGen_ecdsa3 + Run("ssh-keygen -t ecdsa -b 521") + Case $Menu_PrivKey + $KeySel = FileOpenDialog("Select Private Key",@UserProfileDir & "\.ssh","All (*)|KeyFile (*.key)|KeyFile ECDSA (*.ecdsa)",1) + $sshvt_cfg_priv = $KeySel + UpdateConfig() + + Case $Menu_ProfileRename + $NewName = InputBox("PROFILE RENAME " & $CurrentName,"New Name ?",$sshvt_cfg_profile,"","",125) + $sshvt_cfg_profile = $NewName + UpdateConfig() + + Case $Cmd + Run("cmd",@UserProfileDir) + + Case $Pass + UpdateConfigNoReload() + Run("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host) + + Case $Priv + UpdateConfigNoReload() + ConsoleWrite("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host & " -i" & " " & $sshvt_cfg_priv) + Run("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host & " -i" & " " & $sshvt_cfg_priv) + + Case $Menu_ReloadCfgNr + Reload() + + Case $Menu_ReloadCfgWr + UpdateConfig() + + EndSwitch +WEnd + +Func UpdateConfig() + IniWrite($sshvt_config,"SSHVT","Profile Name",$sshvt_cfg_profile) + IniWrite($sshvt_config,"SSHVT","Private Key",$sshvt_cfg_priv) + $sshvt_cfg_host = GUICtrlRead($Host) + IniWrite($sshvt_config,"SSHVT","Host",$sshvt_cfg_host) + $sshvt_cfg_port = GUICtrlRead($Port) + IniWrite($sshvt_config,"SSHVT","Port",$sshvt_cfg_port) + $sshvt_cfg_user = GUICtrlRead($User) + IniWrite($sshvt_config,"SSHVT","User",$sshvt_cfg_user) + Reload() +EndFunc + +Func UpdateConfigNoReload() + IniWrite($sshvt_config,"SSHVT","Profile Name",$sshvt_cfg_profile) + IniWrite($sshvt_config,"SSHVT","Private Key",$sshvt_cfg_priv) + $sshvt_cfg_host = GUICtrlRead($Host) + IniWrite($sshvt_config,"SSHVT","Host",$sshvt_cfg_host) + $sshvt_cfg_port = GUICtrlRead($Port) + IniWrite($sshvt_config,"SSHVT","Port",$sshvt_cfg_port) + $sshvt_cfg_user = GUICtrlRead($User) + IniWrite($sshvt_config,"SSHVT","User",$sshvt_cfg_user) + Return True +EndFunc + +Func Reload() + Run(@AutoItExe) + Exit(0) +EndFunc diff --git a/SSH-VT/SSH-VT.au3 b/SSH-VT/SSH-VT.au3 new file mode 100755 index 0000000..f8e1115 --- /dev/null +++ b/SSH-VT/SSH-VT.au3 @@ -0,0 +1,176 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=SSH.ico +#AutoIt3Wrapper_Outfile=Releases\SSHVT_x32.exe +#AutoIt3Wrapper_Outfile_x64=Releases\SSHVT_x64.exe +#AutoIt3Wrapper_Compile_Both=y +#AutoIt3Wrapper_Res_Comment=SSH-VirtualTerm (SSHVT) +#AutoIt3Wrapper_Res_Description=SSH-VirtualTerm (SSHVT) +#AutoIt3Wrapper_Res_Fileversion=1.2.0.6 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=SSH-VirtualTerm +#AutoIt3Wrapper_Res_ProductVersion=1.2.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + + +GetSoftDetails(@AutoItExe,"RELEASE") + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +$sshvt_config = @UserProfileDir & "\.ssh\sshvt_" & @UserName +if not FileExists($sshvt_config) Then + IniWrite($sshvt_config,"SSHVT","Profile Name","Default") + IniWrite($sshvt_config,"SSHVT","Private Key",@UserProfileDir & "\.ssh\id_rsa") + IniWrite($sshvt_config,"SSHVT","Host","localhost") + IniWrite($sshvt_config,"SSHVT","Port","22") + IniWrite($sshvt_config,"SSHVT","User",@UserName) +EndIf + +$sshvt_cfg_profile = IniRead($sshvt_config,"SSHVT","Profile Name","Default") +$sshvt_cfg_priv = IniRead($sshvt_config,"SSHVT","Private Key",@UserProfileDir & "\.ssh\id_rsa") +$sshvt_cfg_host = IniRead($sshvt_config,"SSHVT","Host","localhost") +$sshvt_cfg_port = IniRead($sshvt_config,"SSHVT","Port","22") +$sshvt_cfg_user = IniRead($sshvt_config,"SSHVT","User",@UserName) + +#include +#include +#include +#include +#include +#Region ### START Koda GUI section ### Form= +Global $Form1 = GUICreate("SecureSHell - " & $sshvt_cfg_profile, 522, 125, 276, 544) +GUISetFont("10","","","Segoe UI") +GUISetBkColor($CurrentAccent) +Global $Group1 = GUICtrlCreateGroup(" SecureShell Settings ", 0, 0, 521, 90) +Global $User = GUICtrlCreateInput($sshvt_cfg_user, 128, 20, 180, 21) +Global $Host = GUICtrlCreateInput($sshvt_cfg_host, 128, 43, 180, 21) +Global $Port = GUICtrlCreateInput($sshvt_cfg_port, 128, 66, 180, 21) +Global $Priv = GUICtrlCreateButton("PRIVKEY MODE", 320, 9, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $Pass = GUICtrlCreateButton("PASSWORD MODE", 320, 35, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $Cmd = GUICtrlCreateButton("OPEN CONSOLE", 320, 61, 200, 25) +GUICtrlSetFont(-1,"12",900) +Global $LUser = GUICtrlCreateLabel("USERNAME", 6, 20, 90, 17) +Global $LHost = GUICtrlCreateLabel("HOSTNAME", 6, 43, 90, 17) +Global $LPass = GUICtrlCreateLabel("PORT", 6, 66, 90, 17) +GUICtrlCreateGroup("", -99, -99, 1, 1) +Global $SoftLine = GUICtrlCreateLabel($CurrentName & " " & $CurrentVersion & " " & $CurrentBaseVersion, 1, 90, 519, 17) +Global $Menu = GUICtrlCreateMenu("Configuration") +Global $Menu_PrivKey = GUICtrlCreateMenuItem("Select Private Key" & @TAB & $sshvt_cfg_priv,$Menu) +Global $Menu_PrivKeyMenu = GUICtrlCreateMenu("Create a New Key",$Menu) +Global $Menu_PrivKeyGen_rsa2 = GUICtrlCreateMenuItem("RSA" & @TAB & "2048bits (normal)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa3 = GUICtrlCreateMenuItem("RSA" & @TAB & "3072bits (high)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa4 = GUICtrlCreateMenuItem("RSA" & @TAB & "4096bits (ultra)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_rsa1 = GUICtrlCreateMenuItem("RSA" & @TAB & "1024bits (low)",$Menu_PrivKeyMenu) +GUICtrlCreateMenuItem("",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa1 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "256bits (low)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa2 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "384bits (medium)",$Menu_PrivKeyMenu) +Global $Menu_PrivKeyGen_ecdsa3 = GUICtrlCreateMenuItem("ECDSA" & @TAB & "521bits (high)",$Menu_PrivKeyMenu) +GUICtrlCreateMenuItem("",$Menu) +Global $Menu_ReloadCfgNr = GUICtrlCreateMenuItem("Configuration Reload (N)" & @TAB & "NO WRITE / RELOAD ONLY",$Menu) +Global $Menu_ReloadCfgWr = GUICtrlCreateMenuItem("Configuration Reload (W)" & @TAB & "OVERWRITE / UPDATE",$Menu) +GUICtrlCreateMenuItem("",$Menu) +Global $Menu_ProfileRename = GUICtrlCreateMenuItem("Rename your Profile",$Menu) +Global $Menu_About = GUICtrlCreateMenu("About") +Global $Menu_About_D = GUICtrlCreateMenuItem("Devs",$Menu_About) +GUICtrlCreateMenuItem("",$Menu_About) +Global $Menu_About_T = GUICtrlCreateMenuItem("Website",$Menu_About) +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + Case $Menu_About_D + TyleoAbout($CurrentName) + Case $Menu_About_T + ShellExecute("https://tyleodev.fr") + Case $Menu_PrivKeyGen_rsa2 + Run("ssh-keygen") + Case $Menu_PrivKeyGen_rsa3 + Run("ssh-keygen -b 3072") + Case $Menu_PrivKeyGen_rsa4 + Run("ssh-keygen -b 4096") + Case $Menu_PrivKeyGen_rsa1 + Run("ssh-keygen -b 1024") + Case $Menu_PrivKeyGen_ecdsa1 + Run("ssh-keygen -t ecdsa -b 256") + Case $Menu_PrivKeyGen_ecdsa2 + Run("ssh-keygen -t ecdsa -b 384") + Case $Menu_PrivKeyGen_ecdsa3 + Run("ssh-keygen -t ecdsa -b 521") + Case $Menu_PrivKey + $KeySel = FileOpenDialog("Select Private Key",@UserProfileDir & "\.ssh","All (*)|KeyFile (*.key)|KeyFile ECDSA (*.ecdsa)",1) + $sshvt_cfg_priv = $KeySel + UpdateConfig() + + Case $Menu_ProfileRename + $NewName = InputBox("PROFILE RENAME " & $CurrentName,"New Name ?",$sshvt_cfg_profile,"","",125) + $sshvt_cfg_profile = $NewName + UpdateConfig() + + Case $Cmd + Run("cmd",@UserProfileDir) + + Case $Pass + UpdateConfigNoReload() + Run("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host) + + Case $Priv + UpdateConfigNoReload() + ConsoleWrite("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host & " -i" & " " & $sshvt_cfg_priv) + Run("ssh -p " & $sshvt_cfg_port & " " & $sshvt_cfg_user & "@" & $sshvt_cfg_host & " -i" & " " & $sshvt_cfg_priv) + + Case $Menu_ReloadCfgNr + Reload() + + Case $Menu_ReloadCfgWr + UpdateConfig() + + EndSwitch +WEnd + +Func UpdateConfig() + IniWrite($sshvt_config,"SSHVT","Profile Name",$sshvt_cfg_profile) + IniWrite($sshvt_config,"SSHVT","Private Key",$sshvt_cfg_priv) + $sshvt_cfg_host = GUICtrlRead($Host) + IniWrite($sshvt_config,"SSHVT","Host",$sshvt_cfg_host) + $sshvt_cfg_port = GUICtrlRead($Port) + IniWrite($sshvt_config,"SSHVT","Port",$sshvt_cfg_port) + $sshvt_cfg_user = GUICtrlRead($User) + IniWrite($sshvt_config,"SSHVT","User",$sshvt_cfg_user) + Reload() +EndFunc + +Func UpdateConfigNoReload() + IniWrite($sshvt_config,"SSHVT","Profile Name",$sshvt_cfg_profile) + IniWrite($sshvt_config,"SSHVT","Private Key",$sshvt_cfg_priv) + $sshvt_cfg_host = GUICtrlRead($Host) + IniWrite($sshvt_config,"SSHVT","Host",$sshvt_cfg_host) + $sshvt_cfg_port = GUICtrlRead($Port) + IniWrite($sshvt_config,"SSHVT","Port",$sshvt_cfg_port) + $sshvt_cfg_user = GUICtrlRead($User) + IniWrite($sshvt_config,"SSHVT","User",$sshvt_cfg_user) + Return True +EndFunc + +Func Reload() + Run(@AutoItExe) + Exit(0) +EndFunc diff --git a/SSH-VT/SSH.ico b/SSH-VT/SSH.ico new file mode 100755 index 0000000..4e647b8 Binary files /dev/null and b/SSH-VT/SSH.ico differ diff --git a/SSH-VT/SSH.png b/SSH-VT/SSH.png new file mode 100755 index 0000000..09e2d04 Binary files /dev/null and b/SSH-VT/SSH.png differ diff --git a/SSH-VT/SSH_M.ico b/SSH-VT/SSH_M.ico new file mode 100755 index 0000000..bcd7e57 Binary files /dev/null and b/SSH-VT/SSH_M.ico differ diff --git a/SSH-VT/SSH_M.png b/SSH-VT/SSH_M.png new file mode 100755 index 0000000..d108788 Binary files /dev/null and b/SSH-VT/SSH_M.png differ diff --git a/SSH-VT/SSH_V.ico b/SSH-VT/SSH_V.ico new file mode 100755 index 0000000..daab3ec Binary files /dev/null and b/SSH-VT/SSH_V.ico differ diff --git a/SSH-VT/SSH_V.png b/SSH-VT/SSH_V.png new file mode 100755 index 0000000..4e4f07d Binary files /dev/null and b/SSH-VT/SSH_V.png differ diff --git a/SSH-VT/sshvt_tyleo b/SSH-VT/sshvt_tyleo new file mode 100755 index 0000000..7f1bf8d --- /dev/null +++ b/SSH-VT/sshvt_tyleo @@ -0,0 +1,6 @@ +[SSHVT] +Profile Name=Default +Private Key=C:\Users\tyleo\.ssh\id_rsa +Host=localhost +Port=22 +User=tyleo diff --git a/TixRusher/Extensions.au3 b/TixRusher/Extensions.au3 new file mode 100755 index 0000000..4c3ee19 --- /dev/null +++ b/TixRusher/Extensions.au3 @@ -0,0 +1,34 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +; Color Accent +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +; Software Base Details +Func GetSoftDetails($Exe,$Stage) + Global $CurrentVersion,$CurrentName,$CurrentBaseVersion + $CurrentVersion = FileGetVersion($Exe,$FV_FILEVERSION) + $CurrentBaseVersion = FileGetVersion($Exe,$FV_PRODUCTVERSION) + $CurrentName = FileGetVersion($Exe,$FV_PRODUCTNAME) + if $Stage = "BETA" Then + $CurrentVersion = $CurrentVersion & "-beta" + Elseif $Stage = "RELEASE" or $Stage = "STABLE" Then + $CurrentVersion = $CurrentVersion & "-rel" + Else + $CurrentVersion = $CurrentVersion & "-dev" + EndIf + Return True +EndFunc + +; About Us +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/TixRusher/MetroGUI-UDF/MetroGUI_UDF.au3 b/TixRusher/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/TixRusher/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/TixRusher/MetroGUI-UDF/MetroThemes.au3 b/TixRusher/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/TixRusher/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/TixRusher/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/TixRusher/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/TixRusher/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/TixRusher/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/TixRusher/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/TixRusher/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/TixRusher/MetroGUI-UDF/_GUIDisable.au3 b/TixRusher/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/TixRusher/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/TixRusher/Releases/.media b/TixRusher/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/TixRusher/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) + diff --git a/TixRusher/TixRusher.au3 b/TixRusher/TixRusher.au3 new file mode 100755 index 0000000..c667625 --- /dev/null +++ b/TixRusher/TixRusher.au3 @@ -0,0 +1,84 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Res_Comment=Tix Rusher +#AutoIt3Wrapper_Res_Fileversion=1.0.0.1 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=TixRusher +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.1 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + +GetSoftDetails(@AutoItExe,"DEV") + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +#include +#include +#include +#include +#include +#Region ### START Koda GUI section ### Form=H:\TixRusher\Projet.kxf + +$CurrentVer = FileGetVersion(@AutoItExe) + +Global $Form1 = GUICreate("TixRusher - Go Quick & Fine " & $CurrentVer, 618, 254, 192, 154) +GUISetFont(10, 400, 0, "Segoe UI") +Global $Files = GUICtrlCreateMenu("Files") +Global $ExitRun = GUICtrlCreateMenuItem("ExitRun", $Files) +Global $Tix = GUICtrlCreateMenu("Tix") +Global $OpenTixBase = GUICtrlCreateMenuItem("Open Tix Base", $Tix) +Global $ClearTixBase = GUICtrlCreateMenuItem("Clear Tix Base", $Tix) +Global $Label2 = GUICtrlCreateLabel("Utilisateur", 5, 9, 70, 23) +GUICtrlSetFont(-1, 12, 400, 0, "Segoe UI") +Global $Label3 = GUICtrlCreateLabel("Poste", 5, 32, 41, 23) +GUICtrlSetFont(-1, 12, 400, 0, "Segoe UI") +Global $Label4 = GUICtrlCreateLabel("Descriptif Rapide", 258, 66, 100, 19, $SS_CENTER) +Global $Username = GUICtrlCreateInput("", 81, 7, 418, 23) +Global $Login = GUICtrlCreateInput("", 500, 7, 109, 23) +Global $Poste = GUICtrlCreateInput("", 50, 32, 294, 23) +Global $Phone = GUICtrlCreateInput("", 372, 33, 239, 23) +Global $Desc = GUICtrlCreateEdit("", 1, 86, 615, 146) +Global $Label1 = GUICtrlCreateLabel("Tel.", 346, 34, 25, 23) +Global $Validate = GUICtrlCreateButton("Validate", 433, 60, 177, 23) +GUICtrlSetStyle(-1, $BS_DEFPUSHBUTTON) +GUICtrlSetFont(-1, 12, 400, 0, "Segoe UI") +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + Case $Validate + + + + + GUICtrlSetData($Username,"Next !") + GUICtrlSetData($Login,"Next !") + GUICtrlSetData($Poste,"Next !") + GUICtrlSetData($Phone,"Next !") + GUICtrlSetData($Desc,"Next !") + Sleep(500) + GUICtrlSetData($Username,"") + GUICtrlSetData($Login,"") + GUICtrlSetData($Poste,"") + GUICtrlSetData($Phone,"") + GUICtrlSetData($Desc,"") + + + EndSwitch +WEnd diff --git a/WSA-ADB Apk Installer/APK/Dolphin - Copie (2).apk b/WSA-ADB Apk Installer/APK/Dolphin - Copie (2).apk new file mode 100755 index 0000000..540c53a Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Dolphin - Copie (2).apk differ diff --git a/WSA-ADB Apk Installer/APK/Dolphin - Copie (3).apk b/WSA-ADB Apk Installer/APK/Dolphin - Copie (3).apk new file mode 100755 index 0000000..540c53a Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Dolphin - Copie (3).apk differ diff --git a/WSA-ADB Apk Installer/APK/Dolphin - Copie - Copie (2).apk b/WSA-ADB Apk Installer/APK/Dolphin - Copie - Copie (2).apk new file mode 100755 index 0000000..540c53a Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Dolphin - Copie - Copie (2).apk differ diff --git a/WSA-ADB Apk Installer/APK/Dolphin - Copie - Copie.apk b/WSA-ADB Apk Installer/APK/Dolphin - Copie - Copie.apk new file mode 100755 index 0000000..540c53a Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Dolphin - Copie - Copie.apk differ diff --git a/WSA-ADB Apk Installer/APK/Dolphin-Browser.apk b/WSA-ADB Apk Installer/APK/Dolphin-Browser.apk new file mode 100755 index 0000000..540c53a Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Dolphin-Browser.apk differ diff --git a/WSA-ADB Apk Installer/APK/Dolphin.apk b/WSA-ADB Apk Installer/APK/Dolphin.apk new file mode 100755 index 0000000..540c53a Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Dolphin.apk differ diff --git a/WSA-ADB Apk Installer/APK/F-Droid - Copie (3).apk b/WSA-ADB Apk Installer/APK/F-Droid - Copie (3).apk new file mode 100755 index 0000000..35047e7 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/F-Droid - Copie (3).apk differ diff --git a/WSA-ADB Apk Installer/APK/F-Droid - Copie - Copie.apk b/WSA-ADB Apk Installer/APK/F-Droid - Copie - Copie.apk new file mode 100755 index 0000000..35047e7 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/F-Droid - Copie - Copie.apk differ diff --git a/WSA-ADB Apk Installer/APK/F-Droid---Copie-(2).apk b/WSA-ADB Apk Installer/APK/F-Droid---Copie-(2).apk new file mode 100755 index 0000000..35047e7 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/F-Droid---Copie-(2).apk differ diff --git a/WSA-ADB Apk Installer/APK/Flow_vFlow_apkpure.com - Copie (3).apk b/WSA-ADB Apk Installer/APK/Flow_vFlow_apkpure.com - Copie (3).apk new file mode 100755 index 0000000..e56a122 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Flow_vFlow_apkpure.com - Copie (3).apk differ diff --git a/WSA-ADB Apk Installer/APK/Flow_vFlow_apkpure.com---Copie-(2).apk b/WSA-ADB Apk Installer/APK/Flow_vFlow_apkpure.com---Copie-(2).apk new file mode 100755 index 0000000..e56a122 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Flow_vFlow_apkpure.com---Copie-(2).apk differ diff --git a/WSA-ADB Apk Installer/APK/Flow_vFlow_apkpure.com---Copie---Copie-(2).apk b/WSA-ADB Apk Installer/APK/Flow_vFlow_apkpure.com---Copie---Copie-(2).apk new file mode 100755 index 0000000..e56a122 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Flow_vFlow_apkpure.com---Copie---Copie-(2).apk differ diff --git a/WSA-ADB Apk Installer/APK/Flow_vFlow_apkpure.com---Copie---Copie.apk b/WSA-ADB Apk Installer/APK/Flow_vFlow_apkpure.com---Copie---Copie.apk new file mode 100755 index 0000000..e56a122 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Flow_vFlow_apkpure.com---Copie---Copie.apk differ diff --git a/WSA-ADB Apk Installer/APK/KeePassDX-3.0.2 - Copie (2).apk b/WSA-ADB Apk Installer/APK/KeePassDX-3.0.2 - Copie (2).apk new file mode 100755 index 0000000..64ae7da Binary files /dev/null and b/WSA-ADB Apk Installer/APK/KeePassDX-3.0.2 - Copie (2).apk differ diff --git a/WSA-ADB Apk Installer/APK/KeePassDX-3.0.2 - Copie (3).apk b/WSA-ADB Apk Installer/APK/KeePassDX-3.0.2 - Copie (3).apk new file mode 100755 index 0000000..64ae7da Binary files /dev/null and b/WSA-ADB Apk Installer/APK/KeePassDX-3.0.2 - Copie (3).apk differ diff --git a/WSA-ADB Apk Installer/APK/KeePassDX-3.0.2 - Copie - Copie (2).apk b/WSA-ADB Apk Installer/APK/KeePassDX-3.0.2 - Copie - Copie (2).apk new file mode 100755 index 0000000..64ae7da Binary files /dev/null and b/WSA-ADB Apk Installer/APK/KeePassDX-3.0.2 - Copie - Copie (2).apk differ diff --git a/WSA-ADB Apk Installer/APK/KeePassDX-3.0.2 - Copie - Copie.apk b/WSA-ADB Apk Installer/APK/KeePassDX-3.0.2 - Copie - Copie.apk new file mode 100755 index 0000000..64ae7da Binary files /dev/null and b/WSA-ADB Apk Installer/APK/KeePassDX-3.0.2 - Copie - Copie.apk differ diff --git a/WSA-ADB Apk Installer/APK/KeePassDX-3.0.2 - Copie.apk b/WSA-ADB Apk Installer/APK/KeePassDX-3.0.2 - Copie.apk new file mode 100755 index 0000000..64ae7da Binary files /dev/null and b/WSA-ADB Apk Installer/APK/KeePassDX-3.0.2 - Copie.apk differ diff --git a/WSA-ADB Apk Installer/APK/KeePassDX-3.0.2.apk b/WSA-ADB Apk Installer/APK/KeePassDX-3.0.2.apk new file mode 100755 index 0000000..64ae7da Binary files /dev/null and b/WSA-ADB Apk Installer/APK/KeePassDX-3.0.2.apk differ diff --git a/WSA-ADB Apk Installer/APK/LADB v1.7 - Mod - Armeabi-v7a - Copie (2).apk b/WSA-ADB Apk Installer/APK/LADB v1.7 - Mod - Armeabi-v7a - Copie (2).apk new file mode 100755 index 0000000..4ecfeba Binary files /dev/null and b/WSA-ADB Apk Installer/APK/LADB v1.7 - Mod - Armeabi-v7a - Copie (2).apk differ diff --git a/WSA-ADB Apk Installer/APK/LADB v1.7 - Mod - Armeabi-v7a - Copie (3).apk b/WSA-ADB Apk Installer/APK/LADB v1.7 - Mod - Armeabi-v7a - Copie (3).apk new file mode 100755 index 0000000..4ecfeba Binary files /dev/null and b/WSA-ADB Apk Installer/APK/LADB v1.7 - Mod - Armeabi-v7a - Copie (3).apk differ diff --git a/WSA-ADB Apk Installer/APK/LADB v1.7 - Mod - Armeabi-v7a - Copie - Copie (2).apk b/WSA-ADB Apk Installer/APK/LADB v1.7 - Mod - Armeabi-v7a - Copie - Copie (2).apk new file mode 100755 index 0000000..4ecfeba Binary files /dev/null and b/WSA-ADB Apk Installer/APK/LADB v1.7 - Mod - Armeabi-v7a - Copie - Copie (2).apk differ diff --git a/WSA-ADB Apk Installer/APK/LADB v1.7 - Mod - Armeabi-v7a - Copie - Copie.apk b/WSA-ADB Apk Installer/APK/LADB v1.7 - Mod - Armeabi-v7a - Copie - Copie.apk new file mode 100755 index 0000000..4ecfeba Binary files /dev/null and b/WSA-ADB Apk Installer/APK/LADB v1.7 - Mod - Armeabi-v7a - Copie - Copie.apk differ diff --git a/WSA-ADB Apk Installer/APK/LADB v1.7 - Mod - Armeabi-v7a - Copie.apk b/WSA-ADB Apk Installer/APK/LADB v1.7 - Mod - Armeabi-v7a - Copie.apk new file mode 100755 index 0000000..4ecfeba Binary files /dev/null and b/WSA-ADB Apk Installer/APK/LADB v1.7 - Mod - Armeabi-v7a - Copie.apk differ diff --git a/WSA-ADB Apk Installer/APK/LADB v1.7 - Mod - Armeabi-v7a.apk b/WSA-ADB Apk Installer/APK/LADB v1.7 - Mod - Armeabi-v7a.apk new file mode 100755 index 0000000..4ecfeba Binary files /dev/null and b/WSA-ADB Apk Installer/APK/LADB v1.7 - Mod - Armeabi-v7a.apk differ diff --git a/WSA-ADB Apk Installer/APK/LADB-1.7 - Copie (2).apk b/WSA-ADB Apk Installer/APK/LADB-1.7 - Copie (2).apk new file mode 100755 index 0000000..4ecfeba Binary files /dev/null and b/WSA-ADB Apk Installer/APK/LADB-1.7 - Copie (2).apk differ diff --git a/WSA-ADB Apk Installer/APK/LADB-1.7 - Copie (3).apk b/WSA-ADB Apk Installer/APK/LADB-1.7 - Copie (3).apk new file mode 100755 index 0000000..4ecfeba Binary files /dev/null and b/WSA-ADB Apk Installer/APK/LADB-1.7 - Copie (3).apk differ diff --git a/WSA-ADB Apk Installer/APK/LADB-1.7 - Copie - Copie (2).apk b/WSA-ADB Apk Installer/APK/LADB-1.7 - Copie - Copie (2).apk new file mode 100755 index 0000000..4ecfeba Binary files /dev/null and b/WSA-ADB Apk Installer/APK/LADB-1.7 - Copie - Copie (2).apk differ diff --git a/WSA-ADB Apk Installer/APK/LADB-1.7 - Copie - Copie.apk b/WSA-ADB Apk Installer/APK/LADB-1.7 - Copie - Copie.apk new file mode 100755 index 0000000..4ecfeba Binary files /dev/null and b/WSA-ADB Apk Installer/APK/LADB-1.7 - Copie - Copie.apk differ diff --git a/WSA-ADB Apk Installer/APK/LADB-1.7 - Copie.apk b/WSA-ADB Apk Installer/APK/LADB-1.7 - Copie.apk new file mode 100755 index 0000000..4ecfeba Binary files /dev/null and b/WSA-ADB Apk Installer/APK/LADB-1.7 - Copie.apk differ diff --git a/WSA-ADB Apk Installer/APK/LADB-1.7.apk b/WSA-ADB Apk Installer/APK/LADB-1.7.apk new file mode 100755 index 0000000..4ecfeba Binary files /dev/null and b/WSA-ADB Apk Installer/APK/LADB-1.7.apk differ diff --git a/WSA-ADB Apk Installer/APK/Nova-Launcher-Prime-v6.2.15-Mod-Pixel-www.ReXdl.com - Copie (2).apk b/WSA-ADB Apk Installer/APK/Nova-Launcher-Prime-v6.2.15-Mod-Pixel-www.ReXdl.com - Copie (2).apk new file mode 100755 index 0000000..62fd733 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Nova-Launcher-Prime-v6.2.15-Mod-Pixel-www.ReXdl.com - Copie (2).apk differ diff --git a/WSA-ADB Apk Installer/APK/Nova-Launcher-Prime-v6.2.15-Mod-Pixel-www.ReXdl.com - Copie (3).apk b/WSA-ADB Apk Installer/APK/Nova-Launcher-Prime-v6.2.15-Mod-Pixel-www.ReXdl.com - Copie (3).apk new file mode 100755 index 0000000..62fd733 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Nova-Launcher-Prime-v6.2.15-Mod-Pixel-www.ReXdl.com - Copie (3).apk differ diff --git a/WSA-ADB Apk Installer/APK/Nova-Launcher-Prime-v6.2.15-Mod-Pixel-www.ReXdl.com - Copie - Copie (2).apk b/WSA-ADB Apk Installer/APK/Nova-Launcher-Prime-v6.2.15-Mod-Pixel-www.ReXdl.com - Copie - Copie (2).apk new file mode 100755 index 0000000..62fd733 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Nova-Launcher-Prime-v6.2.15-Mod-Pixel-www.ReXdl.com - Copie - Copie (2).apk differ diff --git a/WSA-ADB Apk Installer/APK/Nova-Launcher-Prime-v6.2.15-Mod-Pixel-www.ReXdl.com - Copie - Copie.apk b/WSA-ADB Apk Installer/APK/Nova-Launcher-Prime-v6.2.15-Mod-Pixel-www.ReXdl.com - Copie - Copie.apk new file mode 100755 index 0000000..62fd733 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Nova-Launcher-Prime-v6.2.15-Mod-Pixel-www.ReXdl.com - Copie - Copie.apk differ diff --git a/WSA-ADB Apk Installer/APK/Nova-Launcher-Prime-v6.2.15-Mod-Pixel-www.ReXdl.com - Copie.apk b/WSA-ADB Apk Installer/APK/Nova-Launcher-Prime-v6.2.15-Mod-Pixel-www.ReXdl.com - Copie.apk new file mode 100755 index 0000000..62fd733 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Nova-Launcher-Prime-v6.2.15-Mod-Pixel-www.ReXdl.com - Copie.apk differ diff --git a/WSA-ADB Apk Installer/APK/Nova-Launcher-Prime-v6.2.15-Mod-Pixel-www.ReXdl.com.apk b/WSA-ADB Apk Installer/APK/Nova-Launcher-Prime-v6.2.15-Mod-Pixel-www.ReXdl.com.apk new file mode 100755 index 0000000..62fd733 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Nova-Launcher-Prime-v6.2.15-Mod-Pixel-www.ReXdl.com.apk differ diff --git a/WSA-ADB Apk Installer/APK/Nova7-Prime-v7.0.49_build_70049-Mod_R - Copie (2).apk b/WSA-ADB Apk Installer/APK/Nova7-Prime-v7.0.49_build_70049-Mod_R - Copie (2).apk new file mode 100755 index 0000000..2b47fd9 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Nova7-Prime-v7.0.49_build_70049-Mod_R - Copie (2).apk differ diff --git a/WSA-ADB Apk Installer/APK/Nova7-Prime-v7.0.49_build_70049-Mod_R - Copie (3).apk b/WSA-ADB Apk Installer/APK/Nova7-Prime-v7.0.49_build_70049-Mod_R - Copie (3).apk new file mode 100755 index 0000000..2b47fd9 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Nova7-Prime-v7.0.49_build_70049-Mod_R - Copie (3).apk differ diff --git a/WSA-ADB Apk Installer/APK/Nova7-Prime-v7.0.49_build_70049-Mod_R - Copie - Copie (2).apk b/WSA-ADB Apk Installer/APK/Nova7-Prime-v7.0.49_build_70049-Mod_R - Copie - Copie (2).apk new file mode 100755 index 0000000..2b47fd9 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Nova7-Prime-v7.0.49_build_70049-Mod_R - Copie - Copie (2).apk differ diff --git a/WSA-ADB Apk Installer/APK/Nova7-Prime-v7.0.49_build_70049-Mod_R - Copie - Copie.apk b/WSA-ADB Apk Installer/APK/Nova7-Prime-v7.0.49_build_70049-Mod_R - Copie - Copie.apk new file mode 100755 index 0000000..2b47fd9 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Nova7-Prime-v7.0.49_build_70049-Mod_R - Copie - Copie.apk differ diff --git a/WSA-ADB Apk Installer/APK/Nova7-Prime-v7.0.49_build_70049-Mod_R - Copie.apk b/WSA-ADB Apk Installer/APK/Nova7-Prime-v7.0.49_build_70049-Mod_R - Copie.apk new file mode 100755 index 0000000..2b47fd9 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Nova7-Prime-v7.0.49_build_70049-Mod_R - Copie.apk differ diff --git a/WSA-ADB Apk Installer/APK/Nova7-Prime-v7.0.49_build_70049-Mod_R.apk b/WSA-ADB Apk Installer/APK/Nova7-Prime-v7.0.49_build_70049-Mod_R.apk new file mode 100755 index 0000000..2b47fd9 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Nova7-Prime-v7.0.49_build_70049-Mod_R.apk differ diff --git a/WSA-ADB Apk Installer/APK/Smart-Launcher-5-v5.4-build-043-Mod-www.ReXdl.com - Copie (2).apk b/WSA-ADB Apk Installer/APK/Smart-Launcher-5-v5.4-build-043-Mod-www.ReXdl.com - Copie (2).apk new file mode 100755 index 0000000..fa31960 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Smart-Launcher-5-v5.4-build-043-Mod-www.ReXdl.com - Copie (2).apk differ diff --git a/WSA-ADB Apk Installer/APK/Smart-Launcher-5-v5.4-build-043-Mod-www.ReXdl.com - Copie (3).apk b/WSA-ADB Apk Installer/APK/Smart-Launcher-5-v5.4-build-043-Mod-www.ReXdl.com - Copie (3).apk new file mode 100755 index 0000000..fa31960 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Smart-Launcher-5-v5.4-build-043-Mod-www.ReXdl.com - Copie (3).apk differ diff --git a/WSA-ADB Apk Installer/APK/Smart-Launcher-5-v5.4-build-043-Mod-www.ReXdl.com - Copie - Copie (2).apk b/WSA-ADB Apk Installer/APK/Smart-Launcher-5-v5.4-build-043-Mod-www.ReXdl.com - Copie - Copie (2).apk new file mode 100755 index 0000000..fa31960 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Smart-Launcher-5-v5.4-build-043-Mod-www.ReXdl.com - Copie - Copie (2).apk differ diff --git a/WSA-ADB Apk Installer/APK/Smart-Launcher-5-v5.4-build-043-Mod-www.ReXdl.com - Copie - Copie.apk b/WSA-ADB Apk Installer/APK/Smart-Launcher-5-v5.4-build-043-Mod-www.ReXdl.com - Copie - Copie.apk new file mode 100755 index 0000000..fa31960 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Smart-Launcher-5-v5.4-build-043-Mod-www.ReXdl.com - Copie - Copie.apk differ diff --git a/WSA-ADB Apk Installer/APK/Smart-Launcher-5-v5.4-build-043-Mod-www.ReXdl.com - Copie.apk b/WSA-ADB Apk Installer/APK/Smart-Launcher-5-v5.4-build-043-Mod-www.ReXdl.com - Copie.apk new file mode 100755 index 0000000..fa31960 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Smart-Launcher-5-v5.4-build-043-Mod-www.ReXdl.com - Copie.apk differ diff --git a/WSA-ADB Apk Installer/APK/Smart-Launcher-5-v5.4-build-043-Mod-www.ReXdl.com.apk b/WSA-ADB Apk Installer/APK/Smart-Launcher-5-v5.4-build-043-Mod-www.ReXdl.com.apk new file mode 100755 index 0000000..fa31960 Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Smart-Launcher-5-v5.4-build-043-Mod-www.ReXdl.com.apk differ diff --git a/WSA-ADB Apk Installer/APK/Sweech - Copie (2).apk b/WSA-ADB Apk Installer/APK/Sweech - Copie (2).apk new file mode 100755 index 0000000..04d1ecd Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Sweech - Copie (2).apk differ diff --git a/WSA-ADB Apk Installer/APK/Sweech - Copie (3).apk b/WSA-ADB Apk Installer/APK/Sweech - Copie (3).apk new file mode 100755 index 0000000..04d1ecd Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Sweech - Copie (3).apk differ diff --git a/WSA-ADB Apk Installer/APK/Sweech - Copie - Copie (2).apk b/WSA-ADB Apk Installer/APK/Sweech - Copie - Copie (2).apk new file mode 100755 index 0000000..04d1ecd Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Sweech - Copie - Copie (2).apk differ diff --git a/WSA-ADB Apk Installer/APK/Sweech - Copie - Copie.apk b/WSA-ADB Apk Installer/APK/Sweech - Copie - Copie.apk new file mode 100755 index 0000000..04d1ecd Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Sweech - Copie - Copie.apk differ diff --git a/WSA-ADB Apk Installer/APK/Sweech - Copie.apk b/WSA-ADB Apk Installer/APK/Sweech - Copie.apk new file mode 100755 index 0000000..04d1ecd Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Sweech - Copie.apk differ diff --git a/WSA-ADB Apk Installer/APK/Sweech.apk b/WSA-ADB Apk Installer/APK/Sweech.apk new file mode 100755 index 0000000..04d1ecd Binary files /dev/null and b/WSA-ADB Apk Installer/APK/Sweech.apk differ diff --git a/WSA-ADB Apk Installer/APK/manager - Copie (2).apk b/WSA-ADB Apk Installer/APK/manager - Copie (2).apk new file mode 100755 index 0000000..755504d Binary files /dev/null and b/WSA-ADB Apk Installer/APK/manager - Copie (2).apk differ diff --git a/WSA-ADB Apk Installer/APK/manager - Copie (3).apk b/WSA-ADB Apk Installer/APK/manager - Copie (3).apk new file mode 100755 index 0000000..755504d Binary files /dev/null and b/WSA-ADB Apk Installer/APK/manager - Copie (3).apk differ diff --git a/WSA-ADB Apk Installer/APK/manager - Copie - Copie (2).apk b/WSA-ADB Apk Installer/APK/manager - Copie - Copie (2).apk new file mode 100755 index 0000000..755504d Binary files /dev/null and b/WSA-ADB Apk Installer/APK/manager - Copie - Copie (2).apk differ diff --git a/WSA-ADB Apk Installer/APK/manager - Copie - Copie.apk b/WSA-ADB Apk Installer/APK/manager - Copie - Copie.apk new file mode 100755 index 0000000..755504d Binary files /dev/null and b/WSA-ADB Apk Installer/APK/manager - Copie - Copie.apk differ diff --git a/WSA-ADB Apk Installer/APK/manager - Copie.apk b/WSA-ADB Apk Installer/APK/manager - Copie.apk new file mode 100755 index 0000000..755504d Binary files /dev/null and b/WSA-ADB Apk Installer/APK/manager - Copie.apk differ diff --git a/WSA-ADB Apk Installer/APK/manager.apk b/WSA-ADB Apk Installer/APK/manager.apk new file mode 100755 index 0000000..755504d Binary files /dev/null and b/WSA-ADB Apk Installer/APK/manager.apk differ diff --git a/WSA-ADB Apk Installer/MetroGUI-UDF/MetroGUI_UDF.au3 b/WSA-ADB Apk Installer/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/WSA-ADB Apk Installer/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/WSA-ADB Apk Installer/MetroGUI-UDF/MetroThemes.au3 b/WSA-ADB Apk Installer/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/WSA-ADB Apk Installer/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/WSA-ADB Apk Installer/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/WSA-ADB Apk Installer/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/WSA-ADB Apk Installer/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/WSA-ADB Apk Installer/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/WSA-ADB Apk Installer/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/WSA-ADB Apk Installer/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/WSA-ADB Apk Installer/MetroGUI-UDF/_GUIDisable.au3 b/WSA-ADB Apk Installer/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/WSA-ADB Apk Installer/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/WSA-ADB Apk Installer/TyleoAboutMe.au3 b/WSA-ADB Apk Installer/TyleoAboutMe.au3 new file mode 100755 index 0000000..75ff526 --- /dev/null +++ b/WSA-ADB Apk Installer/TyleoAboutMe.au3 @@ -0,0 +1,10 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/WSA-ADB Apk Installer/Untitled design (7).ico b/WSA-ADB Apk Installer/Untitled design (7).ico new file mode 100755 index 0000000..cb2075f Binary files /dev/null and b/WSA-ADB Apk Installer/Untitled design (7).ico differ diff --git a/WSA-ADB Apk Installer/WSA-ADB Apk Installer.au3 b/WSA-ADB Apk Installer/WSA-ADB Apk Installer.au3 new file mode 100755 index 0000000..a2d409b --- /dev/null +++ b/WSA-ADB Apk Installer/WSA-ADB Apk Installer.au3 @@ -0,0 +1,216 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=Untitled design (7).ico +#AutoIt3Wrapper_Outfile_x64=..\..\Logiciels\WSA-APKManager.Exe +#AutoIt3Wrapper_Res_Comment=WSA APK Manager +#AutoIt3Wrapper_Res_Description=WSA APK Manager +#AutoIt3Wrapper_Res_Fileversion=1.0.0.2 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=WSA APK Manager +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "TyleoAboutMe.au3" + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +if RegRead("HKEY_CURRENT_USER\Software\Classes\wsa","URL Protocol") Then + MsgBox(0+16,"Error !","No WSA Installed on your System.") + Exit(1) +Else + ; OK +EndIf + +$State = " STABLE" + +$CurrentVer = FileGetVersion(@AutoItExe) +$CurrentVer = $CurrentVer & $State + +$ProgName = "WSA-APK Installer/Manager " & $CurrentVer & @CRLF & "This App are not affiliated" & @CRLF & "with Microsoft Corporation or WSA Devs" + +#include +#include +#include +#include +#include "WinAccent.au3" +#Region ### START Koda GUI section ### Form= + +$WSAAPK_Data = @ScriptDir + +if Run("adb connect 127.0.0.1:58526") Then + +Else + MsgBox(0+16,"Error, No ADB","No ADB Installed.") +EndIf + +if FileExists($WSAAPK_Data) Then + ; Nothing +Else + DirCreate($WSAAPK_Data) +EndIf + +$Apks = $WSAAPK_Data & "\APK" +if FileExists($Apks) Then + ;Nothing +Else + DirCreate($Apks) + MsgBox(0,"Data Folder Created","Add your APK's in it using explorer or this program." & @CRLF & "Location : " & @AppDataDir & "\WSA-Tyleo") +EndIf + + +Global $GUI = GUICreate("WSA-APK Installer/Manager " & $CurrentVer, 474, 437, 261, 174) +Global $Actions = GUICtrlCreateMenu("Actions") +Global $Actions_All = GUICtrlCreateMenuItem("Install All", $Actions) +Global $Actions_Sel = GUICtrlCreateMenuItem("Install Selected", $Actions) +Global $Actions_S1 = GUICtrlCreateMenuItem("",$Actions) +Global $Actions_Connect = GUICtrlCreateMenuItem("Connect ADB" & @TAB & "127.0.0.1:58526",$Actions) +Global $Actions_ConnectCustom = GUICtrlCreateMenuItem("Connect ADB" & @TAB & "Custom IP/Port",$Actions) +Global $Actions_S2 = GUICtrlCreateMenuItem("",$Actions) +Global $Actions_FixApkName = GUICtrlCreateMenuItem("Fix APK Spaces",$Actions) +Global $Actions_FIxAllSpaces = GUICtrlCreateMenuItem("Fix All APK Names Spaces",$Actions) +Global $Manage = GUICtrlCreateMenu("Manage") +Global $Manage_Add = GUICtrlCreateMenuItem("Add APK", $Manage) +Global $Manage_Remove = GUICtrlCreateMenuItem("Remove APK", $Manage) +Global $Manage_Rename = GUICtrlCreateMenuItem("Rename APK", $Manage) +Global $About = GUICtrlCreateMenu("About") +Global $About_Dev = GUICtrlCreateMenuItem("About Us",$About) +Global $About_Ver = GUICtrlCreateMenuItem("WSA-APK Installer/Manager " & $CurrentVer,$About) +GUICtrlSetState($About_Ver, $GUI_DISABLE) +Global $ApkBank = GUICtrlCreateList("", 0, 0, 473, 418, -1, 0) +GUICtrlSetBkColor($ApkBank,$CurrentAccent) +GUICtrlSetColor($ApkBank,0xFFFFFF) +GUICtrlSetFont($ApkBank,13,900,"","Segoe UI") + +$ButtonBKColor = $CurrentAccent + +EmptyBankCheck($ApkBank) + +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +RefreshApkBank($Apks, $ApkBank) + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + + Case $Manage_Add + $lBrowse = FileSaveDialog("Select APK File to Add",@DesktopDir,"APK (*.apk)") + ConsoleWrite($lBrowse) + FileCopy($lBrowse, @ScriptDir & "\APK") + RefreshApkBank($Apks, $ApkBank) + + EmptyBankCheck($ApkBank) + + Case $Manage_Remove + + $dTarg = GUICtrlRead($ApkBank) + $dTargFull = @ScriptDir & "\APK\" & $dTarg & ".apk" + $Confirm = MsgBox(4,"Remove ?","Are you sure to remove " & $dTarg & " ?") + + if $Confirm = "6" Then + FileDelete($dTargFull) + RefreshApkBank($Apks, $ApkBank) + EndIf + + EmptyBankCheck($ApkBank) + + Case $Manage_Rename + $rTarg = GUICtrlRead($ApkBank) + $rTargFull = @ScriptDir & "\APK\" & $rTarg & ".apk" + $rTargNewName = InputBox("Rename APK","Type the new name. Never include extension (.apk)",$rTarg) + FileMove(@ScriptDir & "\APK\" & $rTarg & ".apk", @ScriptDir & "\APK\" & $rTargNewName & ".apk") + FixApkSpaces(@ScriptDir & "\APK\" & $rTargNewName & ".apk") + RefreshApkBank($Apks, $ApkBank) + + Case $Actions_Connect + Run("adb connect 127.0.0.1:58526", @SW_HIDE) + + Case $Actions_ConnectCustom + $CustomIP = InputBox("Type Custom IP:Port","IP:Port","127.0.0.1:58526","",120,120) + Run("adb connect " & $CustomIP, @SW_HIDE) + + Case $Actions_Sel + $InstallApk = GUICtrlRead($ApkBank) + Run("adb install " & ".\APK\" & $InstallApk & ".apk") + + Case $Actions_FixApkName + $ApkToFix = GUICtrlRead($ApkBank) + FixApkSpaces($ApkToFix) + RefreshApkBank($Apks, $ApkBank) + + Case $Actions_FIxAllSpaces + $iApks_pool = _FileListToArray(@ScriptDir & "\APK","*.apk",$FLTA_FILES,True) + For $i In $iApks_pool + FixApkSpacesEx2($i) + ConsoleWrite(@CRLF & $i) + Next + RefreshApkBank($Apks, $ApkBank) + + Case $Actions_All + GUISetState(@SW_HIDE,$GUI) + $iApks_pool = _FileListToArray(".\APK\","*.apk",$FLTA_FILES,True) + For $i In $iApks_pool + FixApkSpaces($i) + Next + + $iApks_pool = _FileListToArray(".\APK\","*.apk",$FLTA_FILES,False) + For $i In $iApks_pool + RunWait("adb install " & $i,@ScriptDir & "\APK", @SW_HIDE) + Next + RefreshApkBank($Apks, $ApkBank) + GUISetState(@SW_SHOW,$GUI) + MsgBox(0,"","Installation Ended.") + + Case $About_Dev + TyleoAbout($ProgName) + + EndSwitch +WEnd + +Func RefreshApkBank($Source, $Controler) + GUICtrlSetData($Controler,"") + $fApks_pool = _FileListToArray($Source,"*.apk",$FLTA_FILES,False) + $fApks = _ArrayDelete($fApks_pool,0) + $fApks = _ArrayTrim($fApks_pool,4,1) + $fApks = _ArrayToString($fApks_pool) + GUICtrlSetData($Controler,$fApks) + Return True +EndFunc + +Func FixApkSpaces($Target) + $fName = $Target & ".apk" + $fName = StringReplace($fName, " ", "-") + FileMove(".\APK\" & $Target & ".apk",".\APK\" & $fName) + ConsoleWrite(@CRLF & "Tried to process : " & $fName & "BY|ON" & $Target) + Return True +EndFunc + +Func FixApkSpacesEx2($Target) + $fName = $Target + $fName = StringReplace($fName, " ", "-") + FileMove($Target,".\APK\" & $fName & ".apk") + ConsoleWrite(@CRLF & "Tried to process : " & $fName & "BY|ON" & $Target) + Return True +EndFunc + +Func EmptyBankCheck($Controler) + $BankData = GUICtrlRead($Controler) + if $BankData = "-1" Then + GUICtrlSetData($Controler,"No APK Files, Add Files with menu !") + Return 76 + EndIf +EndFunc \ No newline at end of file diff --git a/WSA-ADB Apk Installer/WinAccent.au3 b/WSA-ADB Apk Installer/WinAccent.au3 new file mode 100755 index 0000000..9bd9398 --- /dev/null +++ b/WSA-ADB Apk Installer/WinAccent.au3 @@ -0,0 +1,17 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. + +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor \ No newline at end of file diff --git a/Win11-Tools/TaskbarPos/DefaultPos.reg b/Win11-Tools/TaskbarPos/DefaultPos.reg new file mode 100755 index 0000000..7a24533 Binary files /dev/null and b/Win11-Tools/TaskbarPos/DefaultPos.reg differ diff --git a/Win11-Tools/TaskbarPos/TaskbarPos-Changer.au3 b/Win11-Tools/TaskbarPos/TaskbarPos-Changer.au3 new file mode 100755 index 0000000..011f8db --- /dev/null +++ b/Win11-Tools/TaskbarPos/TaskbarPos-Changer.au3 @@ -0,0 +1,54 @@ +#include +#include +#include +#Region ### START Koda GUI section ### Form= +Global $Form1 = GUICreate("TaskBar Pos", 240, 100, 270, 197) +Global $ToTop = GUICtrlCreateButton("Taskbar to Top", 8, 48, 225, 33) +Global $ToBottom = GUICtrlCreateButton("Taskbar to Bottom (Default)", 8, 16, 225, 33) +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +HotKeySet("e",ExpLoad) + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + Case $ToTop + ShellExecute(@ScriptDir & "\TopPos.reg") + MsgBox(0,"Reload Explorer","Click OK to reload explorer now !") + Run("taskkill /im explorer.exe /f") + Sleep(250) + Run("explorer.exe") + Run("taskkill /im explorer.exe /f") + Sleep(250) + Run("explorer.exe") + Run("taskkill /im explorer.exe /f") + Sleep(250) + Run("explorer.exe") + Run("taskkill /im explorer.exe /f") + Sleep(250) + Run("explorer.exe") + Case $ToBottom + ShellExecute(@ScriptDir & "\DefaultPos.reg") + MsgBox(0,"Reload Explorer","Click OK to reload explorer now !") + Run("taskkill /im explorer.exe /f") + Sleep(250) + Run("explorer.exe") + Run("taskkill /im explorer.exe /f") + Sleep(250) + Run("explorer.exe") + Run("taskkill /im explorer.exe /f") + Sleep(250) + Run("explorer.exe") + Run("taskkill /im explorer.exe /f") + Sleep(250) + Run("explorer.exe") + + EndSwitch +WEnd + +Func ExpLoad() + Run("explorer.exe") +EndFunc \ No newline at end of file diff --git a/Win11-Tools/TaskbarPos/TaskbarPos-Changer.exe b/Win11-Tools/TaskbarPos/TaskbarPos-Changer.exe new file mode 100755 index 0000000..f873b4f Binary files /dev/null and b/Win11-Tools/TaskbarPos/TaskbarPos-Changer.exe differ diff --git a/Win11-Tools/TaskbarPos/TopPos.reg b/Win11-Tools/TaskbarPos/TopPos.reg new file mode 100755 index 0000000..afeae2c Binary files /dev/null and b/Win11-Tools/TaskbarPos/TopPos.reg differ diff --git a/YAWAT/Extensions.au3 b/YAWAT/Extensions.au3 new file mode 100755 index 0000000..e4f06b5 --- /dev/null +++ b/YAWAT/Extensions.au3 @@ -0,0 +1,48 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +; Color Accent +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +; Color Accent Refresh +Func ColorReload() +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor +EndFunc + +; Software Base Details +Func GetSoftDetails($Exe,$Stage) + Global $CurrentVersion,$CurrentName,$CurrentBaseVersion + $CurrentVersion = FileGetVersion($Exe,$FV_FILEVERSION) + $CurrentBaseVersion = FileGetVersion($Exe,$FV_PRODUCTVERSION) + $CurrentName = FileGetVersion($Exe,$FV_PRODUCTNAME) + if $Stage = "BETA" Then + $CurrentVersion = $CurrentVersion & "-beta" + Elseif $Stage = "RELEASE" or $Stage = "STABLE" Then + $CurrentVersion = $CurrentVersion & "-rel" + Else + $CurrentVersion = $CurrentVersion & "-dev" + EndIf + Return True +EndFunc + +; About Us +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2022" & @CRLF & " " & @CRLF & "MAKE IT HAPPENING" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "support@tyleodev.fr",400,15) + Return True +EndFunc + +; Main Website Open Handle +Func TyleoWebsite() + ShellExecute("https://tyleodev.fr") +EndFunc \ No newline at end of file diff --git a/YAWAT/MetroGUI-UDF/MetroGUI_UDF.au3 b/YAWAT/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/YAWAT/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/YAWAT/MetroGUI-UDF/MetroThemes.au3 b/YAWAT/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/YAWAT/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/YAWAT/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/YAWAT/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/YAWAT/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/YAWAT/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/YAWAT/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/YAWAT/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/YAWAT/MetroGUI-UDF/_GUIDisable.au3 b/YAWAT/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/YAWAT/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/YAWAT/Projet.kxf b/YAWAT/Projet.kxf new file mode 100755 index 0000000..dd97fb4 --- /dev/null +++ b/YAWAT/Projet.kxf @@ -0,0 +1,179 @@ + + + + 703 + 331 + 471 + 233 + Form1 + clBtnFace + DEFAULT_CHARSET + clWindowText + -11 + MS Sans Serif + + Menu1 + False + True + -1798701056 + 256 + 1.04 + False + False + False + False + -1 + 1 + 0 + 1 + + 96 + 13 + + + + + 4 + 3 + 28 + 28 + Owner + MainMenu1 + + + + + + 34 + 3 + 28 + 28 + PopupMenu1 + + + + + + 4 + 0 + 217 + 65 + Button1 + 0 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 4 + 64 + 217 + 65 + Button1 + 1 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 236 + 0 + 217 + 65 + Button1 + 2 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + 236 + 64 + 217 + 65 + Button1 + 3 + clBtnFace + 1342373888 + 0 + DockWidth, DockHeight + + + + + + + + + MenuItem1 + + + + + + MenuItem2 + + + + + + MenuItem3 + + + + + + MenuItem9 + + + + + + MenuItem8 + + + + + + MenuItem7 + + + + + + MenuItem6 + + + + + + MenuItem5 + + + + + + MenuItem4 + + + + + + + + + + + \ No newline at end of file diff --git a/YAWAT/README.md b/YAWAT/README.md new file mode 100755 index 0000000..ce6d680 --- /dev/null +++ b/YAWAT/README.md @@ -0,0 +1 @@ +Logiciel Tyleo Créé avec CNP \ No newline at end of file diff --git a/YAWAT/Releases/.media b/YAWAT/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/YAWAT/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) + diff --git a/YAWAT/Releases/yawa-toolbox-legacy32.exe b/YAWAT/Releases/yawa-toolbox-legacy32.exe new file mode 100755 index 0000000..9cf970d Binary files /dev/null and b/YAWAT/Releases/yawa-toolbox-legacy32.exe differ diff --git a/YAWAT/Releases/yawa-toolbox.exe b/YAWAT/Releases/yawa-toolbox.exe new file mode 100755 index 0000000..6240b00 Binary files /dev/null and b/YAWAT/Releases/yawa-toolbox.exe differ diff --git a/YAWAT/Untitled-1.ps1 b/YAWAT/Untitled-1.ps1 new file mode 100755 index 0000000..ca704c4 --- /dev/null +++ b/YAWAT/Untitled-1.ps1 @@ -0,0 +1,6 @@ +$portvalue = 49560 + +Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber" -Value $portvalue + +New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Profile 'Public' -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portvalue +New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Profile 'Public' -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portvalue \ No newline at end of file diff --git a/YAWAT/YAWAT.au3 b/YAWAT/YAWAT.au3 new file mode 100755 index 0000000..2831c90 --- /dev/null +++ b/YAWAT/YAWAT.au3 @@ -0,0 +1,772 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=YAWAT.ico +#AutoIt3Wrapper_Outfile=C:\Users\tyleo\Nextcloud\Tyleo\Logiciels\YAWAT\yawa-toolbox-legacy32.exe +#AutoIt3Wrapper_Outfile_x64=C:\Users\tyleo\Nextcloud\Tyleo\Logiciels\YAWAT\yawa-toolbox.exe +#AutoIt3Wrapper_Compile_Both=y +#AutoIt3Wrapper_Res_Comment=Yet Another Windows Admin Toolbox - By TyleoDev +#AutoIt3Wrapper_Res_Description=Yet Another Windows Admin Toolbox - By TyleoDev +#AutoIt3Wrapper_Res_Fileversion=1.0.0.18 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductName=Yet Another Windows Admin Toolbox +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +; BeAdmin +if IsAdmin() Then + $BeAdmin = "(Admin Mode)" + $AsAdmin = 1 +Else + $BeAdmin = "(User Mode)" + $AsAdmin = 0 +EndIf +; + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + +GetSoftDetails(@AutoItExe,"DEV") +$SVer = "YAWAT " & $CurrentVersion + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + +$ActiveUser = @UserName +$ActiveProfile = @UserProfileDir +$ActiveSysDir = @SystemDir +$LocalHost = @ComputerName + +#include +#include +#include +#include +#include + +#Region ### START Koda GUI section ### Form= +Global $GUI_Main_Frame = GUICreate($SVer & " | Logged in as " & $ActiveUser & " " & $BeAdmin, 651, 60) +GUISetBkColor($CurrentAccent,$GUI_Main_Frame) +GUISetFont(11.5,"","","Segoe UI",$GUI_Main_Frame) + +; Systéme +Global $Menu_Sys = GUICtrlCreateMenu("Systeme") +Global $Menu_Sys_Run = GUICtrlCreateMenuItem("Executer (Systéme)",$Menu_Sys) +Global $Menu_Sys_RunB = GUICtrlCreateMenuItem("Executer (Toolbox)",$Menu_Sys) +GUICtrlCreateMenuItem("",$Menu_Sys) +Global $Menu_Sys_CfgPanelOld = GUICtrlCreateMenuItem("Panneau de Configuration" & @TAB & "Original",$Menu_Sys) +Global $Menu_Sys_CfgPanelNew = GUICtrlCreateMenuItem("Panneau de Configuration" & @TAB & "Next Gen",$Menu_Sys) +GUICtrlCreateMenuItem("",$Menu_Sys) +Global $Menu_Sys_AdmTools = GUICtrlCreateMenuItem("Outils d'Administration Windows",$Menu_Sys) +GUICtrlCreateMenuItem("",$Menu_Sys) +Global $Menu_Sys_SwitchtoAdmin = GUICtrlCreateMenuItem("Relancer YAWAT en Administrateur" & @TAB & "SWITCH",$Menu_Sys) + + +; Consoles +Global $Menu_Csl = GUICtrlCreateMenu("Consoles") +Global $Menu_Csl_Tpm = GUICtrlCreateMenuItem("Trusted Platform Module" & @TAB & "MMC",$Menu_Csl) +Global $Menu_Csl_Services = GUICtrlCreateMenuItem("Services" & @TAB & "MMC",$Menu_Csl) +Global $Menu_Csl_Crt = GUICtrlCreateMenuItem("Certificats" & @TAB & "MMC",$Menu_Csl) +Global $Menu_Csl_DiskMgmt = GUICtrlCreateMenuItem("Disques" & @TAB & "MMC",$Menu_Csl) +Global $Menu_Csl_GPLocal = GUICtrlCreateMenuItem("Politique de Groupes" & @TAB & "MMC",$Menu_Csl) +Global $Menu_Csl_GPSecur = GUICtrlCreateMenuItem("Politique Sécurité Locale" & @TAB & "MMC",$Menu_Csl) +GUICtrlCreateMenuItem("",$Menu_Csl) +Global $Menu_Csl_GPResul = GUICtrlCreateMenuItem("Politique Résultantes" & @TAB & "RSoP",$Menu_Csl) +Global $Menu_Csl_Wfw = GUICtrlCreateMenuItem("Pare-Feu interne Windows" & @TAB & "Control",$Menu_Csl) + +; Users & Groups +Global $Menu_Ugr = GUICtrlCreateMenu("Utilisateurs && Groupes") +Global $Menu_Ugr_Console = GUICtrlCreateMenuItem("Gestionnaire Utilisateurs et Groupes locaux",$Menu_Ugr) +GUICtrlCreateMenuItem("",$Menu_Ugr) +GUICtrlCreateMenuItem("" & @TAB & "Utilisateurs",$Menu_Ugr) +GUICtrlSetState(-1,$GUI_DISABLE) +Global $Menu_Ugr_Add = GUICtrlCreateMenuItem("Création d'un Utilisateur" & @TAB & "ADDUSR",$Menu_Ugr) +Global $Menu_Ugr_Del = GUICtrlCreateMenuItem("Suppression d'un Utilisateur" & @TAB & "DELUSR",$Menu_Ugr) +GUICtrlCreateMenuItem("",$Menu_Ugr) +GUICtrlCreateMenuItem("" & @TAB & "Groupes",$Menu_Ugr) +GUICtrlSetState(-1,$GUI_DISABLE) +Global $Menu_Ugr_Grp_Add = GUICtrlCreateMenuItem("Création d'un Groupe" & @TAB & "ADDGRP",$Menu_Ugr) +Global $Menu_Ugr_Grp_Del = GUICtrlCreateMenuItem("Suppression d'un Groupe" & @TAB & "DELGRP",$Menu_Ugr) +GUICtrlCreateMenuItem("",$Menu_Ugr) +GUICtrlCreateMenuItem("" & @TAB & "Gestion des Groupes",$Menu_Ugr) +GUICtrlSetState(-1,$GUI_DISABLE) +Global $Menu_Ugr_Grp_Man_AddUserTo = GUICtrlCreateMenuItem("Ajouter un utilisateur dans un groupe" & @TAB & "ADDUSERTOGRP",$Menu_Ugr) +GUICtrlCreateMenuItem("",$Menu_Ugr) +GUICtrlCreateMenuItem("" & @TAB & "Visualiser les infos",$Menu_Ugr) +GUICtrlSetState(-1,$GUI_DISABLE) +Global $Menu_Ugr_Grp_Man_ListUsers = GUICtrlCreateMenuItem("Voir la liste des utilisateurs d'un groupe",$Menu_Ugr) +Global $Menu_Ugr_GetInfo = GUICtrlCreateMenuItem("Afficher les infos d'un utilisateur" & @TAB & "CURRENTUSER",$Menu_Ugr) +Global $Menu_Ugr_GetInfo_Spec = GUICtrlCreateMenuItem("Afficher les infos d'un utilisateur" & @TAB & "SPECIFICUSER", $Menu_Ugr) + +; Commandes +Global $Menu_Cmd = GUICtrlCreateMenu("Commandes") +Global $Menu_Cmd_SFC = GUICtrlCreateMenuItem("Lancer le Scan auto SFC avec Scannow" & @TAB & "SFCSCAN",$Menu_Cmd) +Global $Menu_Cmd_DISM_Scan = GUICtrlCreateMenuItem("Scan DISM Santé du Systéme" & @TAB & "SCANDISMHEALTH",$Menu_Cmd) +Global $Menu_Cmd_DISM_Rest = GUICtrlCreateMenuItem("Restaurer la santé du systéme - DISM Restore" & @TAB & "RESTOREDISMHEALTH",$Menu_Cmd) +GUICtrlCreateMenuItem("",$Menu_Cmd) +GUICtrlCreateMenuItem("" & @TAB & "Commandes de Vérification du Systéme de Fichiers",$Menu_Cmd) +GUICtrlSetState(-1,$GUI_DISABLE) +Global $Menu_Cmd_CHK_C = GUICtrlCreateMenuItem("Vérifier et Réparer le Systéme de Fichier sur C:\" & @TAB & "CHKFIXSYSTEMDRIVE",$Menu_Cmd) +Global $Menu_Cmd_CHK_SPEC = GUICtrlCreateMenuItem("Vérifier et Réparer le Systéme de Fichier sur un lecteur défini" & @TAB & "CHKFIXSPECDRIVE",$Menu_Cmd) +GUICtrlCreateMenuItem("",$Menu_Cmd) +GUICtrlCreateMenuItem("" & @TAB & "Commandes de test Ping Spécifiques",$Menu_Cmd) +GUICtrlSetState(-1,$GUI_DISABLE) +Global $Menu_Cmd_PNG_HOST = GUICtrlCreateMenuItem("Ping vers l'Hôte (%COMPUTERNAME%)" & @TAB & "PINGHOST",$Menu_Cmd) +Global $Menu_Cmd_PNG_LOCAL = GUICtrlCreateMenuItem("Ping vers LocalHost" & @TAB & "PINGLOCAL",$Menu_Cmd) +Global $Menu_Cmd_PNG_INTERNALV6 = GUICtrlCreateMenuItem("Ping vers l'IPv6 Interne (::1)" & @TAB & "PINGV6",$Menu_Cmd) +Global $Menu_Cmd_PNG_INTERNALV4 = GUICtrlCreateMenuItem("Ping vers l'IPv4 Interne (127.0.0.1)" & @TAB & "PINGV4",$Menu_Cmd) +GUICtrlCreateMenuItem("",$Menu_Cmd) +GUICtrlCreateMenuItem("" & @TAB & "Commandes Chocolatey",$Menu_Cmd) +GUICtrlSetState(-1,$GUI_DISABLE) +Global $Menu_Cmd_CHOCOSETUP = GUICtrlCreateMenuItem("Installer Chocolatey Packages Manager for Windows" & @TAB & "CHOCOSETUP",$Menu_Cmd) +GUICtrlCreateMenuItem("--------------------- Paquets Choco ---------------------",$Menu_Cmd) +GUICtrlSetState(-1,$GUI_DISABLE) +Global $Menu_Cmd_CHOCOPKG_RECPACK = GUICtrlCreateMenuItem("Pack recommandé par Tyleo" & @TAB & "SETUPRECPACK",$Menu_Cmd) + + +; Gestion DNS +Global $Menu_DNS = GUICtrlCreateMenu("Gestion DNS") +Global $Menu_DNS_Clear = GUICtrlCreateMenuItem("Nettoyage par FlushDNS" & @TAB & "FLUSHDNS",$Menu_DNS) +Global $Menu_DNS_Console = GUICtrlCreateMenuItem("Console DNS Locale (Client)" & @TAB & "CSLDNS",$Menu_DNS) +GUICtrlCreateMenuItem("",$Menu_DNS) +GUICtrlCreateMenuItem("" & @TAB & "Informations DNS",$Menu_DNS) +GUICtrlSetState(-1,$GUI_DISABLE) +Global $Menu_DNS_GETINFO = GUICtrlCreateMenuItem("Voir la configuration DNS" & @TAB & "DNSGETINFO",$Menu_DNS) + +; Gestion IP / NETWORK +Global $Menu_NET = GUICtrlCreateMenu("Gestion IP") +Global $Menu_NET_IPCFG_EASY = GUICtrlCreateMenuItem("Informations IP (Simple)" & @TAB & "IPCFGEASY",$Menu_NET) +Global $Menu_NET_IPCFG_ADVC = GUICtrlCreateMenuItem("Informations IP (Avancé)" & @TAB & "IPCFGADVC",$Menu_NET) +Global $Menu_NET_GetMacV = GUICtrlCreateMenuItem("Liste des MAC Physiques",$Menu_NET) +GUICtrlCreateMenuItem("",$Menu_NET) +GUICtrlCreateMenuItem("" & @TAB & "Actions Réseau",$Menu_NET) +GUICtrlSetState(-1,$GUI_DISABLE) +Global $Menu_NET_RenewIP = GUICtrlCreateMenuItem("Renouveler l'IP" & @TAB & "IPRENEW",$Menu_NET) +Global $Menu_NET_ReleaseIP = GUICtrlCreateMenuItem("Relacher l'IP sans renouveler" & @TAB & "IPRELEASE",$Menu_NET) +Global $Menu_NET_ReloadCard = GUICtrlCreateMenuItem("Relancer les Services Réseau" & @TAB & "NETCARDSERVICESRELOAD",$Menu_NET) + +; Personnalisation +Global $Menu_Per = GUICtrlCreateMenu("Personnalisation") +Global $Menu_Per_RelColor = GUICtrlCreateMenuItem("Rafraichir Couleur d'Interface",$Menu_Per) + +; Version & Devs +Global $Menu_Ver = GUICtrlCreateMenu("A propos") +Global $Menu_Ver_Dev = GUICtrlCreateMenuItem("Version && Devs",$Menu_Ver) +Global $Menu_Ver_Site = GUICtrlCreateMenuItem("Site Internet" & @TAB & "https://tyleodev.fr",$Menu_Ver) + + + +Global $Button_HOST = GUICtrlCreateInput($LocalHost,5,5,280,32) +GUICtrlSetColor(-1,0xFFFFFF) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetFont(-1,13,900) +Global $Button_PING = GUICtrlCreateButton("PING",287,5,50) +GUICtrlSetColor(-1,0xFFFFFF) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetCursor(-1,0) +Global $Button_DNS = GUICtrlCreateButton("DNS",337,5,50) +GUICtrlSetColor(-1,0xFFFFFF) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetCursor(-1,0) +Global $Button_WMIC = GUICtrlCreateButton("WMIC",387,5,50) +GUICtrlSetColor(-1,0xFFFFFF) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetCursor(-1,0) +Global $Button_PSH = GUICtrlCreateButton("PSH",437,5,50) +GUICtrlSetColor(-1,0xFFFFFF) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetCursor(-1,0) +Global $Button_CMD = GUICtrlCreateButton("CMD",487,5,50) +GUICtrlSetColor(-1,0xFFFFFF) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetCursor(-1,0) +Global $Button_MMC = GUICtrlCreateButton("MMC",537,5,50) +GUICtrlSetColor(-1,0xFFFFFF) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetCursor(-1,0) +Global $Button_NFO = GUICtrlCreateButton("INFO",587,5,50) +GUICtrlSetColor(-1,0xFFFFFF) +GUICtrlSetBkColor(-1,$CurrentAccent) +GUICtrlSetCursor(-1,0) +GUISetState(@SW_SHOW) +#EndRegion ### END Koda GUI section ### + +; Admin Features +if $AsAdmin = 0 Then + GUICtrlSetState($Menu_Cmd_CHK_C,$GUI_DISABLE) + GUICtrlSetState($Menu_Cmd_CHK_SPEC,$GUI_DISABLE) + GUICtrlSetState($Menu_Cmd_CHOCOPKG_RECPACK,$GUI_DISABLE) + GUICtrlSetState($Menu_Cmd_CHOCOSETUP,$GUI_DISABLE) + GUICtrlSetState($Menu_Cmd_DISM_Rest,$GUI_DISABLE) + GUICtrlSetState($Menu_Cmd_DISM_Scan,$GUI_DISABLE) + GUICtrlSetState($Menu_Cmd_SFC,$GUI_DISABLE) + ;--------------------------------------------------------------- + GUICtrlSetState($Menu_Ugr_Add,$GUI_DISABLE) + GUICtrlSetState($Menu_Ugr_Del,$GUI_DISABLE) + GUICtrlSetState($Menu_Ugr_Grp_Add,$GUI_DISABLE) + GUICtrlSetState($Menu_Ugr_Grp_Del,$GUI_DISABLE) + GUICtrlSetState($Menu_Ugr_Grp_Man_AddUserTo,$GUI_DISABLE) + ;--------------------------------------------------------------- + GUICtrlSetState($Menu_NET_ReleaseIP,$GUI_DISABLE) + GUICtrlSetState($Menu_NET_ReloadCard,$GUI_DISABLE) + GUICtrlSetState($Menu_NET_RenewIP,$GUI_DISABLE) + ;--------------------------------------------------------------- + GUICtrlSetState($Menu_DNS_Console,$GUI_DISABLE) + GUICtrlSetState($Menu_DNS_Clear,$GUI_DISABLE) + ;Boutons-------------------------------------------------------- + GUICtrlSetState($Button_HOST,$GUI_DISABLE) + GUICtrlSetState($Button_MMC,$GUI_DISABLE) + GUICtrlSetState($Button_WMIC,$GUI_DISABLE) + GUICtrlSetState($Button_PSH,$GUI_DISABLE) + GUICtrlSetState($Button_DNS,$GUI_DISABLE) +Else + GUICtrlSetState($Menu_Sys_SwitchtoAdmin,$GUI_DISABLE) + GUICtrlSetData($Menu_Sys_SwitchtoAdmin,"Déjà connecté en Administrateur" & @TAB & "DISABLED") +EndIf + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE + Exit + Case $Menu_Ver_Dev + TyleoAbout("Yet.Another.Windows.Admin.Toolbox " & $SVer) + Case $Menu_Ver_Site + TyleoWebsite() + Case $Menu_Per_RelColor + ColorReload() + GUISetBkColor($CurrentAccent,$GUI_Main_Frame) + + ; Admin Switch + Case $Menu_Sys_SwitchtoAdmin + If @Compiled Then + ShellExecute(@AutoItExe, '', '', 'runas') + Else + ShellExecute(@AutoItExe, '"' & @ScriptFullPath & '"', '', 'runas') + EndIf + if @Error Then + ; Keep Running as User + Else + exit(0) + EndIf + + + ; Fonctions Actives (Boutons) + Case $Button_PING + $InHOST = GUICtrlRead($Button_HOST) + $Nb = InputBox("Nombre de ping pour le test","Choisir le nombre de ping a envoyer. Recommandation : Limitez vous a un maximum de 150 echo (avant Flood)","5") + WaitMsg() + If ($Nb = "") Then + MsgBox(0+16,"Erreur !","Un nombre de ping est nécessaire.") + Else + $OutPING = Run("ping -n " & $Nb & " " & $InHOST,@ScriptDir,@SW_HIDE,$STDOUT_CHILD) + ProcessWaitClose($OutPING) + $OutTrPING = StdoutRead($OutPING) + ClipPut($OutTrPING) + MsgBox(0,"Resultats du Ping - Données envoyées dans votre CTRL+V / +X",$OutTrPING) + EndIf + + Case $Button_DNS + $InHOST = GUICtrlRead($Button_HOST) + $OutDNS = Run("nslookup " & $InHOST,@ScriptDir, @SW_HIDE, $STDOUT_CHILD) + ProcessWaitClose($OutDNS) + $OutTrDNS = StdoutRead($OutDNS) + ClipPut($OutTrDNS) + MsgBox(0,"Resultat NSLookup - Données envoyées dans votre CTRL+V / +X",$OutTrDNS) + + Case $Button_NFO + WaitMsg() + $OutNFO = Run("systeminfo",@ScriptDir,@SW_HIDE,$STDOUT_CHILD) + ProcessWaitClose($OutNFO) + $OutTrNFO = StdoutRead($OutNFO) + ClipPut($OutTrNFO) + MsgBox(0,"System Informations (RAW) - Données envoyées dans votre CTRL+V / +X",$OutTrNFO) + + Case $Button_CMD + Run("cmd") + + Case $Button_PSH + Run("powershell") + + Case $Button_WMIC + Run("wmic") + + Case $Button_MMC + ShellExecute("mmc") + + ;Fonctions Passives (Menus) + ;Source Shell (10/11) : https://winaero.com/windows-11-shell-commands-the-complete-list/ + ;Source Win11 (MSCmd) : https://techzoneonline.com/windows-11-run-commands-list/#Windows-11-Settings---System + + Case $Menu_Sys_Run + ShellExecute("shell:::{2559a1f3-21d7-11d4-bdaf-00c04f60b9f0}") + Case $Menu_Sys_RunB + $TARGET_Program = InputBox("Run","Type the name of a program to run (Will be run in current mode)","","",378, 224) + Run($TARGET_Program) + ; 378, 224 + Case $Menu_Sys_CfgPanelOld + ShellExecute("shell:::{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}") + Case $Menu_Sys_CfgPanelNew + ShellExecute("ms-settings:") + Case $Menu_Sys_AdmTools + ShellExecute("shell:Common Administrative Tools") + + ; Fonctions Passives - Actions CMD + Case $Menu_Cmd_CHK_C + WaitMsg() + $oRun = Run("chkdsk /f", "", @SW_SHOW,$STDOUT_CHILD) + ProcessWaitClose($oRun) + $oTrRun = StdoutRead($oRun) + ClipPut($oTrRun) + MsgBox(0,"ChkDsk Resultats",$oTrRun) + + Case $Menu_Cmd_CHK_SPEC + WaitMsg() + $SelDrive = InputBox("Disque Personnalisé","Disque ?","C") + $pRun = Run("chkdsk /f " & $SelDrive, "", @SW_SHOW,$STDOUT_CHILD) + ProcessWaitClose($pRun) + $pTrRun = StdoutRead($pRun) + ClipPut($pTrRun) + MsgBox(0,"ChkDsk Resultats",$pTrRun) + + Case $Menu_Cmd_CHOCOSETUP + $ChocoGlobal = "feature enable -n=allowGlobalConfirmation" + $ChocoCMD = "Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" + RunWait("powershell" & " " & $ChocoCMD) + RunWait("choco " & " " & $ChocoGlobal) + + Case $Menu_Cmd_CHOCOPKG_RECPACK + Run("choco install curl wget git") + + Case $Menu_Cmd_DISM_Scan + WaitMsg() + $dismcRun = Run("DISM /Online /Cleanup-Image /ScanHealth","", @SW_SHOW,$STDOUT_CHILD) + ProcessWaitClose($dismcRun) + $dismcTrRun = StdoutRead($dismcRun) + ClipPut($dismcTrRun) + MsgBox(0,"SFC Resultats",$dismcTrRun) + + Case $Menu_Cmd_DISM_Rest + WaitMsg() + $dismhRun = Run("DISM /Online /Cleanup-Image /RestoreHealth","", @SW_SHOW,$STDOUT_CHILD) + ProcessWaitClose($dismhRun) + $dismhTrRun = StdoutRead($dismhRun) + ClipPut($dismhTrRun) + MsgBox(0,"SFC Resultats",$dismhTrRun) + + Case $Menu_Cmd_SFC + WaitMsg() + $sfcRun = Run("sfc /scannow","", @SW_SHOW,$STDOUT_CHILD) + ProcessWaitClose($sfcRun) + $sfcTrRun = StdoutRead($sfcRun) + ClipPut($sfcTrRun) + MsgBox(0,"SFC Resultats",$sfcTrRun) + + Case $Menu_Cmd_PNG_LOCAL + WaitMsg() + $pnglRun = Run("ping localhost","", @SW_HIDE,$STDOUT_CHILD) + ProcessWaitClose($pnglRun) + $pTrRun = StdoutRead($pnglRun) + ClipPut($pTrRun) + MsgBox(0,"Ping Resultats",$pTrRun) + + Case $Menu_Cmd_PNG_HOST + WaitMsg() + $p2nglRun = Run("ping " & @ComputerName,"", @SW_HIDE,$STDOUT_CHILD) + ProcessWaitClose($p2nglRun) + $p2TrRun = StdoutRead($p2nglRun) + ClipPut($p2TrRun) + MsgBox(0,"Ping Resultats",$p2TrRun) + + Case $Menu_Cmd_PNG_INTERNALV4 + WaitMsg() + $p3nglRun = Run("ping 127.0.0.1","", @SW_HIDE,$STDOUT_CHILD) + ProcessWaitClose($p3nglRun) + $p3TrRun = StdoutRead($p3nglRun) + ClipPut($p3TrRun) + MsgBox(0,"Ping Resultats",$p3TrRun) + + Case $Menu_Cmd_PNG_INTERNALV6 + WaitMsg() + $p4nglRun = Run("ping ::1","", @SW_HIDE,$STDOUT_CHILD) + ProcessWaitClose($p4nglRun) + $p4TrRun = StdoutRead($p4nglRun) + ClipPut($p4TrRun) + MsgBox(0,"Ping Resultats",$p4TrRun) + + ; NET + Case $Menu_NET_IPCFG_EASY + $ipcfgeRun = Run("ipconfig", "", @SW_HIDE, $STDOUT_CHILD) + ProcessWaitClose($ipcfgeRun) + $ipcfgeTrRun = StdoutRead($ipcfgeRun) + ClipPut($ipcfgeTrRun) + MsgBox(0, "Configuration IP Simple", $ipcfgeTrRun) + + Case $Menu_NET_IPCFG_ADVC + $ipcfgaRun = Run("ipconfig /all", "", @SW_HIDE, $STDOUT_CHILD) + ProcessWaitClose($ipcfgaRun) + $ipcfgaTrRun = StdoutRead($ipcfgaRun) + ClipPut($ipcfgaTrRun) + MsgBox(0, "Configuration IP Avancée", $ipcfgaTrRun) + + Case $Menu_NET_ReleaseIP + $iprlRun = Run("ipconfig /release","",@SW_HIDE,$STDOUT_CHILD) + ProcessWaitClose($iprlRun) + $iprlTrRun = StdoutRead($iprlRun) + ClipPut($iprlTrRun) + MsgBox(0,"IP Relachée", $iprlTrRun) + + Case $Menu_NET_RenewIP + $iprrRun = Run("ipconfig /renew","",@SW_HIDE,$STDOUT_CHILD) + ProcessWaitClose($iprrRun) + $iprrTrRun = StdoutRead($iprrRun) + ClipPut($iprrTrRun) + MsgBox(0,"IP Relachée", $iprrTrRun) + + Case $Menu_NET_ReloadCard + RunWait("net stop WlanSvc", "", @SW_HIDE) + RunWait("sc WlanSvc start", "", @SW_HIDE) + RunWait("net stop WwanSvc", "", @SW_HIDE) + RunWait("sc WwanSvc start", "", @SW_HIDE) + RunWait("net stop IpxlatCfgSvc", "", @SW_HIDE) + RunWait("sc IpxlatCfgSvc start", "", @SW_HIDE) + RunWait("net stop NetSetupSvc", "", @SW_HIDE) + RunWait("sc NetSetupSvc start", "", @SW_HIDE) + RunWait("net stop NcbService", "", @SW_HIDE) + RunWait("sc NcbService start", "", @SW_HIDE) + + Case $Menu_NET_GetMacV + $getmacrun = Run("getmac /FO LIST /V","",@SW_HIDE,$STDOUT_CHILD) + ProcessWaitClose($getmacrun) + $macdata = StdoutRead($getmacrun) + ClipPut($macdata) + MsgBox(0,"Liste des MAC Physiques",$macdata) + + ; DNS + Case $Menu_DNS_Clear + $dnsfRun = Run("ipconfig /flushdns","",@SW_HIDE,$STDOUT_CHILD) + ProcessWaitClose($dnsfRun) + $dnsfTrRun = StdoutRead($dnsfRun) + ClipPut($dnsfTrRun) + MsgBox(0,"DNS Flush", $dnsfTrRun) + + Case $Menu_DNS_Console + LaunchShell("dnsmgmt.msc") + + Case $Menu_DNS_GETINFO + $dnsservers = Run("powershell Get-DnsClientServerAddress | Select-Object –ExpandProperty ServerAddresses","",@SW_HIDE,$STDOUT_CHILD) + $dnsserversTr = StdoutRead($dnsservers) + ProcessWaitClose($dnsservers) + ClipPut($dnsserversTr) + MsgBox(0,"Serveurs DNS",$dnsserversTr) + + ; UGR + Case $Menu_Ugr_Console + ShellExecute("lusrmgr.msc") + + Case $Menu_Ugr_Add + CreateUser() + + Case $Menu_Ugr_Del + DeleteUser() + + Case $Menu_Ugr_Grp_Add + CreateGroup() + + Case $Menu_Ugr_Grp_Del + DeleteGroup() + + Case $Menu_Ugr_GetInfo + $CHX = 0 + $UsernameSel = @UserName + $CHX = MsgBox(4,"Mode","Oui - Mode Simple (par défaut)" & @CRLF & "Non - Mode Avancé" & @CRLF & " " & @CRLF & "Mode par défaut dans 5s",5) + ; GetUserInfo($UsernameSel) + if $CHX = 6 OR $CHX = "-1" Then + GetUserInfo($UsernameSel) + ElseIf $CHX = 7 Then + GetUserInfoEx($UsernameSel) + EndIf + + Case $Menu_Ugr_GetInfo_Spec + $CHX = 0 + $UsernameSel = InputBox("Nom d'utilisateur","Saisir le nom d'utilisateur LDAP (username)") + $CHX = MsgBox(4,"Mode","Oui - Mode Simple (par défaut)" & @CRLF & "Non - Mode Avancé" & @CRLF & " " & @CRLF & "Mode par défaut dans 5s",5) + ; GetUserInfo($UsernameSel) + if $CHX = 6 OR $CHX = "-1" Then + GetUserInfo($UsernameSel) + ElseIf $CHX = 7 Then + GetUserInfoEx($UsernameSel) + EndIf + + Case $Menu_Ugr_Grp_Man_AddUserTo + + Case $Menu_Ugr_Grp_Man_ListUsers + + ; CSL + Case $Menu_Csl_DiskMgmt + LaunchShell("diskmgmt.msc") + Case $Menu_Csl_Crt + LaunchShell("certmgr.msc") + Case $Menu_Csl_GPLocal + LaunchShell("gpedit.msc") + Case $Menu_Csl_GPResul + + Case $Menu_Csl_GPSecur + + Case $Menu_Csl_Services + LaunchShell("services.msc") + Case $Menu_Csl_Tpm + LaunchShell("tpm.msc") + + Case $Menu_Csl_Wfw + LaunchShell("wf.msc") + + EndSwitch +WEnd + +Func WaitMsg() + MsgBox(0,"Veuillez patienter","L'opération peut prendre quelques instants." & @CRLF & "Le logiciel n'est pas utilisable pendant ce laps de temps.",2) +EndFunc + +;------------------------------------ Manage Users ------------------------------------ + +Func CreateUser() + HideMain() + Local $GUI_CreateUser = GUICreate("",350,180) + GUISetFont(14,100,"","Segoe UI",$GUI_CreateUser) + GUISetBkColor($CurrentAccent) + Local $UserLB = GUICtrlCreateLabel("Username :",5,8) + GUICtrlSetColor(-1,0xFFFFFF) + Local $UserID = GUICtrlCreateInput("",100,5,247,30) + GUICtrlSetBkColor(-1,$CurrentAccent) + GUICtrlSetColor(-1,0xFFFFFF) + Local $PassLB = GUICtrlCreateLabel("Password :",5,43) + GUICtrlSetColor(-1,0xFFFFFF) + Local $PassID = GUICtrlCreateInput("123+aze@#s",100,40,247,30) + GUICtrlSetBkColor(-1,$CurrentAccent) + GUICtrlSetColor(-1,0xFFFFFF) + Local $AsAdm = GUICtrlCreateCheckbox("Accés Administrateur",5,80,380,30) + GUICtrlSetBkColor(-1,0xFFFFFF) + Local $AsRdp = GUICtrlCreateCheckbox("Accés Remote Desktop",5,110,380,30) + GUICtrlSetBkColor(-1,0xFFFFFF) + + Local $Cancel = GUICtrlCreateButton("Annuler",5,142,165,35) + GUICtrlSetCursor(-1,0) + + Local $Create = GUICtrlCreateButton("Créer",180,142,165,35) + GUICtrlSetCursor(-1,0) + + GUISetState(@SW_SHOW,$GUI_CreateUser) + + While 1 + $lMsg = GUIGetMsg() + Switch $lMsg + Case $GUI_EVENT_CLOSE,$Cancel + CloseGUI($GUI_CreateUser) + ExitLoop + Case $Create + $usr = GUICtrlRead($UserID) + $pss = GUICtrlRead($PassID) + $adm = GUICtrlRead($AsAdm) + if $adm = $GUI_CHECKED Then + $param_adm = 1 + $settingadm = " Oui" + Else + $param_adm = 0 + $settingadm = " Non" + EndIf + $rdp = GUICtrlRead($AsRdp) + if $rdp = $GUI_CHECKED Then + $param_rdp = 1 + $settingrdp = " Oui" + Else + $param_rdp = 0 + $settingrdp = " Non" + EndIf + ClipPut("Username : " & $usr & @CRLF & "Password : " & $pss & @CRLF & "Admin :" & $settingadm & @CRLF & "RDP :" & $settingrdp) + MsgBox(4,"Définition du nouvel utilisateur","Username : " & $usr & @CRLF & "Password : " & $pss & @CRLF & "Admin :" & $settingadm & @CRLF & "RDP :" & $settingrdp) + ; User Creation + Run("Net User " & $usr & " " & $pss & " /add","",@SW_SHOW) + + ;Admin + if ($param_adm = 1) Then + Sleep(1200) + $edit_grp_run1 = Run('net localgroup "Administrators" ' & $usr & ' /add',"",@SW_HIDE,$STDOUT_CHILD) + ProcessWaitClose($edit_grp_run1) + $grp_tr1 = StdoutRead($edit_grp_run1) + ConsoleWrite($grp_tr1) + EndIf + + ;Rdp + if ($param_rdp = 1) Then + Sleep(1200) + $edit_grp_run2 = Run('net localgroup' & ' "Remote Desktop Users" ' & $usr & ' /add',"",@SW_HIDE,$STDOUT_CHILD) + ProcessWaitClose($edit_grp_run2) + $grp_tr2 = StdoutRead($edit_grp_run2) + ConsoleWrite($grp_tr2) + EndIf + $lMsg = 0 + $param_adm = 0 + $param_rdp = 0 + $settingadm = 0 + $settingrdp = 0 + $usr = 0 + $pss = 0 + $adm = 0 + $rdp = 0 + CloseGUI($GUI_CreateUser) + ;--------------- + EndSwitch + WEnd +EndFunc + +Func GetUserInfo($UsernameID) + $GIRun = Run("powershell Get-ADUser " & $UsernameID,"",@SW_HIDE,$STDOUT_CHILD) + ProcessWaitClose($GIRun) + $GIRunTR = StdoutRead($GIRun) + ClipPut($GIRunTR) + MsgBox(0,"Information Utilisateur " & $UsernameID,$GIRunTR) +EndFunc + +Func GetUserInfoEx($UsernameID) + $GIRun = Run("powershell Get-ADUser " & $UsernameID & " -Properties *","",@SW_HIDE,$STDOUT_CHILD) + ProcessWaitClose($GIRun) + $GIRunTR = StdoutRead($GIRun) + ClipPut($GIRunTR) + MsgBox(0,"Information Utilisateur - Mode Etendue de données - " & $UsernameID,$GIRunTR) +EndFunc + +Func DeleteUser() + +EndFunc + + +Func CreateGroup() + +EndFunc + + +Func DeleteGroup() + +EndFunc + +Func LaunchProgram($program) + Run($program,"",@SW_SHOW) +EndFunc + +Func LaunchShell($shellcommand) + ShellExecute($shellcommand) +EndFunc + +;BuiltinUsersProtection +Func UserProtectCheck($UserID) + if $UserID = "Administrator" OR $UserID = "Administrateur" Then + $IsAdministrator = 1 + EndIf +EndFunc +;-------------------------------------------------------------------------------------- + +Func CloseGUI($GUI) + GUISetState(@SW_HIDE,$GUI) + GUISetState(@SW_SHOW,$GUI_Main_Frame) +EndFunc + +Func HideMain() + GUISetState(@SW_HIDE,$GUI_Main_Frame) +EndFunc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/YAWAT/YAWAT.ico b/YAWAT/YAWAT.ico new file mode 100755 index 0000000..8124d41 Binary files /dev/null and b/YAWAT/YAWAT.ico differ diff --git a/YAWAT/YAWAT.png b/YAWAT/YAWAT.png new file mode 100755 index 0000000..b05d2f3 Binary files /dev/null and b/YAWAT/YAWAT.png differ diff --git a/YTMP3Win/.filerun.versioning/Extensions.au3/1/data b/YTMP3Win/.filerun.versioning/Extensions.au3/1/data new file mode 100755 index 0000000..276228e --- /dev/null +++ b/YTMP3Win/.filerun.versioning/Extensions.au3/1/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647077165;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/YTMP3Win/.filerun.versioning/Extensions.au3/1/file b/YTMP3Win/.filerun.versioning/Extensions.au3/1/file new file mode 100755 index 0000000..4c3ee19 --- /dev/null +++ b/YTMP3Win/.filerun.versioning/Extensions.au3/1/file @@ -0,0 +1,34 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +; Color Accent +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +; Software Base Details +Func GetSoftDetails($Exe,$Stage) + Global $CurrentVersion,$CurrentName,$CurrentBaseVersion + $CurrentVersion = FileGetVersion($Exe,$FV_FILEVERSION) + $CurrentBaseVersion = FileGetVersion($Exe,$FV_PRODUCTVERSION) + $CurrentName = FileGetVersion($Exe,$FV_PRODUCTNAME) + if $Stage = "BETA" Then + $CurrentVersion = $CurrentVersion & "-beta" + Elseif $Stage = "RELEASE" or $Stage = "STABLE" Then + $CurrentVersion = $CurrentVersion & "-rel" + Else + $CurrentVersion = $CurrentVersion & "-dev" + EndIf + Return True +EndFunc + +; About Us +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/YTMP3Win/.filerun.versioning/Extensions.au3/2/data b/YTMP3Win/.filerun.versioning/Extensions.au3/2/data new file mode 100755 index 0000000..99801f8 --- /dev/null +++ b/YTMP3Win/.filerun.versioning/Extensions.au3/2/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647077245;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/YTMP3Win/.filerun.versioning/Extensions.au3/2/file b/YTMP3Win/.filerun.versioning/Extensions.au3/2/file new file mode 100755 index 0000000..10fd066 --- /dev/null +++ b/YTMP3Win/.filerun.versioning/Extensions.au3/2/file @@ -0,0 +1,34 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +; Color Accent +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +; Software Base Details +Func GetSoftDetails($Exe,$Stage) + Global $CurrentVersion,$CurrentName,$CurrentBaseVersion + $CurrentVersion = FileGetVersion($Exe,$FV_FILEVERSION) + $CurrentBaseVersion = FileGetVersion($Exe,$FV_PRODUCTVERSION) + $CurrentName = FileGetVersion($Exe,$FV_PRODUCTNAME) + if $Stage = "BETA" Then + $CurrentVersion = $CurrentVersion & "-beta" + Elseif $Stage = "RELEASE" or $Stage = "STABLE" Then + $CurrentVersion = $CurrentVersion & "-rel" + Else + $CurrentVersion = $CurrentVersion & "-dev" + EndIf + Return True +EndFunc + +; About Us +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2022" & @CRLF & " " & @CRLF & "MAKE IT HAPPENING" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/YTMP3Win/Extensions.au3 b/YTMP3Win/Extensions.au3 new file mode 100755 index 0000000..e4f06b5 --- /dev/null +++ b/YTMP3Win/Extensions.au3 @@ -0,0 +1,48 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +; Color Accent +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +; Color Accent Refresh +Func ColorReload() +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor +EndFunc + +; Software Base Details +Func GetSoftDetails($Exe,$Stage) + Global $CurrentVersion,$CurrentName,$CurrentBaseVersion + $CurrentVersion = FileGetVersion($Exe,$FV_FILEVERSION) + $CurrentBaseVersion = FileGetVersion($Exe,$FV_PRODUCTVERSION) + $CurrentName = FileGetVersion($Exe,$FV_PRODUCTNAME) + if $Stage = "BETA" Then + $CurrentVersion = $CurrentVersion & "-beta" + Elseif $Stage = "RELEASE" or $Stage = "STABLE" Then + $CurrentVersion = $CurrentVersion & "-rel" + Else + $CurrentVersion = $CurrentVersion & "-dev" + EndIf + Return True +EndFunc + +; About Us +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2022" & @CRLF & " " & @CRLF & "MAKE IT HAPPENING" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "support@tyleodev.fr",400,15) + Return True +EndFunc + +; Main Website Open Handle +Func TyleoWebsite() + ShellExecute("https://tyleodev.fr") +EndFunc \ No newline at end of file diff --git a/YTMP3Win/MetroGUI-UDF/MetroGUI_UDF.au3 b/YTMP3Win/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/YTMP3Win/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/YTMP3Win/MetroGUI-UDF/MetroThemes.au3 b/YTMP3Win/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/YTMP3Win/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/YTMP3Win/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/YTMP3Win/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/YTMP3Win/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/YTMP3Win/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/YTMP3Win/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/YTMP3Win/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/YTMP3Win/MetroGUI-UDF/_GUIDisable.au3 b/YTMP3Win/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/YTMP3Win/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/YTMP3Win/Projet.kxf b/YTMP3Win/Projet.kxf new file mode 100755 index 0000000..e8a2629 --- /dev/null +++ b/YTMP3Win/Projet.kxf @@ -0,0 +1,229 @@ + + + + 192 + 154 + 633 + 292 + Form1 + clBtnFace + DEFAULT_CHARSET + clWindowText + -13 + Segoe UI + + Menu1 + False + True + -1798701056 + 256 + 1.04 + False + False + False + False + -1 + 1 + 0 + 1 + + 96 + 15 + + + + + 586 + 56 + 28 + 28 + Owner + MainMenu1 + + + + + + 5 + 9 + 70 + 23 + Utilisateur + DEFAULT_CHARSET + clWindowText + -16 + Segoe UI + + False + 0 + False + 1342308608 + 0 + + + + + + + 5 + 32 + 41 + 23 + Poste + DEFAULT_CHARSET + clWindowText + -16 + Segoe UI + + False + 1 + False + 1342308608 + 0 + + + + + + + 258 + 66 + 100 + 19 + Descriptif Rapide + 2 + False + 1342308609 + 0 + + + + + + + 81 + 7 + 418 + 23 + 3 + Input1 + 1342374016 + 512 + DockHeight + + + + + + 500 + 7 + 109 + 23 + 4 + Input1 + 1342374016 + 512 + DockHeight + + + + + + 50 + 32 + 294 + 23 + 5 + Input3 + 1342374016 + 512 + DockHeight + + + + + + 1 + 86 + 615 + 146 + + +
  • Edit1
  • +
    +
    + 6 + 1345523908 + 512 + +
    + +
    + + + 372 + 33 + 239 + 23 + 7 + Input3 + 1342374016 + 512 + DockHeight + + + + + + 346 + 34 + 25 + 23 + Tel. + DEFAULT_CHARSET + clWindowText + -16 + Segoe UI + + False + 8 + False + 1342308608 + 0 + + + + + + + + + + MenuItem2 + + + + + MenuItem4 + + + + + + + + MenuItem1 + + + + + MenuItem3 + + + + + + + +
    +
    \ No newline at end of file diff --git a/YTMP3Win/README.md b/YTMP3Win/README.md new file mode 100755 index 0000000..ce6d680 --- /dev/null +++ b/YTMP3Win/README.md @@ -0,0 +1 @@ +Logiciel Tyleo Créé avec CNP \ No newline at end of file diff --git a/YTMP3Win/Releases/.media b/YTMP3Win/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/YTMP3Win/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) + diff --git a/YTMP3Win/YTMP3Win.au3 b/YTMP3Win/YTMP3Win.au3 new file mode 100755 index 0000000..9f86f9b --- /dev/null +++ b/YTMP3Win/YTMP3Win.au3 @@ -0,0 +1,45 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=YTMP3Win.ico +#AutoIt3Wrapper_Outfile=ytmp3.exe +#AutoIt3Wrapper_Outfile_x64=ytmp3.exe +#AutoIt3Wrapper_Res_Fileversion=1.0.0.10 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + +GetSoftDetails(@AutoItExe,"DEV") + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce +if $CmdLine[0] = 1 Then + $url = $CmdLine[1] +Else + $url = "" +EndIf +$cmd = 'yt-dlp -i -c --add-metadata --embed-thumbnail --extract-audio --audio-format mp3 --audio-quality 0 --postprocessor-args "-write_id3v1 1 -id3v2_version 3"' + +; Dependancies Checks +Run("ffmpeg","",@SW_HIDE) +if @error Then + MsgBox(0+16,"Error !","FFMPEG Must Be Installed and available in PATH") +EndIf +Run("yt-dlp","",@SW_HIDE) +if @error Then + MsgBox(0+16,"Error !","YT-DLP Must Be Installed and available in PATH") +EndIf +; MsgBox(0,"Debug",$CmdLine[1]) + +Run($cmd & " " & $url) \ No newline at end of file diff --git a/YTMP3Win/YTMP3Win.ico b/YTMP3Win/YTMP3Win.ico new file mode 100755 index 0000000..6c46f3e Binary files /dev/null and b/YTMP3Win/YTMP3Win.ico differ diff --git a/YTMP3Win/ytmp3.exe b/YTMP3Win/ytmp3.exe new file mode 100755 index 0000000..24a56ac Binary files /dev/null and b/YTMP3Win/ytmp3.exe differ diff --git a/YouTube Get GUI/MetroGUI-UDF/MetroGUI_UDF.au3 b/YouTube Get GUI/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/YouTube Get GUI/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/YouTube Get GUI/MetroGUI-UDF/MetroThemes.au3 b/YouTube Get GUI/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/YouTube Get GUI/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/YouTube Get GUI/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/YouTube Get GUI/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/YouTube Get GUI/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/YouTube Get GUI/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/YouTube Get GUI/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/YouTube Get GUI/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/YouTube Get GUI/MetroGUI-UDF/_GUIDisable.au3 b/YouTube Get GUI/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/YouTube Get GUI/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/YouTube Get GUI/Releases/.media b/YouTube Get GUI/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/YouTube Get GUI/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) + diff --git a/YouTube Get GUI/TyleoAboutMe.au3 b/YouTube Get GUI/TyleoAboutMe.au3 new file mode 100755 index 0000000..75ff526 --- /dev/null +++ b/YouTube Get GUI/TyleoAboutMe.au3 @@ -0,0 +1,10 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/YouTube Get GUI/YouTube Get GUI.au3 b/YouTube Get GUI/YouTube Get GUI.au3 new file mode 100755 index 0000000..aa7c211 --- /dev/null +++ b/YouTube Get GUI/YouTube Get GUI.au3 @@ -0,0 +1,23 @@ + +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "TyleoAboutMe.au3" + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + diff --git a/_devtools/.filerun.versioning/Extensions.au3/1/data b/_devtools/.filerun.versioning/Extensions.au3/1/data new file mode 100755 index 0000000..276228e --- /dev/null +++ b/_devtools/.filerun.versioning/Extensions.au3/1/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647077165;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/_devtools/.filerun.versioning/Extensions.au3/1/file b/_devtools/.filerun.versioning/Extensions.au3/1/file new file mode 100755 index 0000000..4c3ee19 --- /dev/null +++ b/_devtools/.filerun.versioning/Extensions.au3/1/file @@ -0,0 +1,34 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +; Color Accent +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +; Software Base Details +Func GetSoftDetails($Exe,$Stage) + Global $CurrentVersion,$CurrentName,$CurrentBaseVersion + $CurrentVersion = FileGetVersion($Exe,$FV_FILEVERSION) + $CurrentBaseVersion = FileGetVersion($Exe,$FV_PRODUCTVERSION) + $CurrentName = FileGetVersion($Exe,$FV_PRODUCTNAME) + if $Stage = "BETA" Then + $CurrentVersion = $CurrentVersion & "-beta" + Elseif $Stage = "RELEASE" or $Stage = "STABLE" Then + $CurrentVersion = $CurrentVersion & "-rel" + Else + $CurrentVersion = $CurrentVersion & "-dev" + EndIf + Return True +EndFunc + +; About Us +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2021" & @CRLF & " " & @CRLF & "BUILDING TOMORROW" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/_devtools/.filerun.versioning/Extensions.au3/2/data b/_devtools/.filerun.versioning/Extensions.au3/2/data new file mode 100755 index 0000000..99801f8 --- /dev/null +++ b/_devtools/.filerun.versioning/Extensions.au3/2/data @@ -0,0 +1 @@ +a:2:{s:4:"date";i:1647077245;s:4:"user";s:9:"Tyleo Dev";} \ No newline at end of file diff --git a/_devtools/.filerun.versioning/Extensions.au3/2/file b/_devtools/.filerun.versioning/Extensions.au3/2/file new file mode 100755 index 0000000..10fd066 --- /dev/null +++ b/_devtools/.filerun.versioning/Extensions.au3/2/file @@ -0,0 +1,34 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +; Color Accent +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +; Software Base Details +Func GetSoftDetails($Exe,$Stage) + Global $CurrentVersion,$CurrentName,$CurrentBaseVersion + $CurrentVersion = FileGetVersion($Exe,$FV_FILEVERSION) + $CurrentBaseVersion = FileGetVersion($Exe,$FV_PRODUCTVERSION) + $CurrentName = FileGetVersion($Exe,$FV_PRODUCTNAME) + if $Stage = "BETA" Then + $CurrentVersion = $CurrentVersion & "-beta" + Elseif $Stage = "RELEASE" or $Stage = "STABLE" Then + $CurrentVersion = $CurrentVersion & "-rel" + Else + $CurrentVersion = $CurrentVersion & "-dev" + EndIf + Return True +EndFunc + +; About Us +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2022" & @CRLF & " " & @CRLF & "MAKE IT HAPPENING" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "tyleo.dev@outlook.com",400,15) + Return True +EndFunc \ No newline at end of file diff --git a/_devtools/Extensions.au3 b/_devtools/Extensions.au3 new file mode 100755 index 0000000..e4f06b5 --- /dev/null +++ b/_devtools/Extensions.au3 @@ -0,0 +1,48 @@ + +#include +#include +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include + +; Color Accent +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor + +; Color Accent Refresh +Func ColorReload() +$theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) +$theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) +$theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) + +$CurrentAccent = $theMWTitleBarColor +EndFunc + +; Software Base Details +Func GetSoftDetails($Exe,$Stage) + Global $CurrentVersion,$CurrentName,$CurrentBaseVersion + $CurrentVersion = FileGetVersion($Exe,$FV_FILEVERSION) + $CurrentBaseVersion = FileGetVersion($Exe,$FV_PRODUCTVERSION) + $CurrentName = FileGetVersion($Exe,$FV_PRODUCTNAME) + if $Stage = "BETA" Then + $CurrentVersion = $CurrentVersion & "-beta" + Elseif $Stage = "RELEASE" or $Stage = "STABLE" Then + $CurrentVersion = $CurrentVersion & "-rel" + Else + $CurrentVersion = $CurrentVersion & "-dev" + EndIf + Return True +EndFunc + +; About Us +Func TyleoAbout($SoftName) + _Metro_MsgBox(8,"About / A propos",$SoftName & @CRLF & "Tyleo Softwares @ 2022" & @CRLF & " " & @CRLF & "MAKE IT HAPPENING" & @CRLF & " " & @CRLF & "This Software is free and Open Source." & @CRLF & "support@tyleodev.fr",400,15) + Return True +EndFunc + +; Main Website Open Handle +Func TyleoWebsite() + ShellExecute("https://tyleodev.fr") +EndFunc \ No newline at end of file diff --git a/_devtools/MetroGUI-UDF/MetroGUI_UDF.au3 b/_devtools/MetroGUI-UDF/MetroGUI_UDF.au3 new file mode 100755 index 0000000..71034f4 --- /dev/null +++ b/_devtools/MetroGUI-UDF/MetroGUI_UDF.au3 @@ -0,0 +1,3575 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;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) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;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) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/_devtools/MetroGUI-UDF/MetroThemes.au3 b/_devtools/MetroGUI-UDF/MetroThemes.au3 new file mode 100755 index 0000000..fd4704a --- /dev/null +++ b/_devtools/MetroGUI-UDF/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/_devtools/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 b/_devtools/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 new file mode 100755 index 0000000..eb284f0 --- /dev/null +++ b/_devtools/MetroGUI-UDF/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/_devtools/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 b/_devtools/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 new file mode 100755 index 0000000..93ec00b --- /dev/null +++ b/_devtools/MetroGUI-UDF/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/_devtools/MetroGUI-UDF/_GUIDisable.au3 b/_devtools/MetroGUI-UDF/_GUIDisable.au3 new file mode 100755 index 0000000..df5b192 --- /dev/null +++ b/_devtools/MetroGUI-UDF/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/_devtools/ProjectBase.au3 b/_devtools/ProjectBase.au3 new file mode 100755 index 0000000..1ab24c7 --- /dev/null +++ b/_devtools/ProjectBase.au3 @@ -0,0 +1,25 @@ + +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y +#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 +#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares +#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include "MetroGUI-UDF\MetroGUI_UDF.au3" +#include "Extensions.au3" + +GetSoftDetails(@AutoItExe,"DEV") + +#cs + + Tyleo Software Project Base v1 + Created With CNP and DevTools Base Folder + + All Softwares created with this base are Free and Open Sourced. + Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp + +#ce + diff --git a/_devtools/Projet.kxf b/_devtools/Projet.kxf new file mode 100755 index 0000000..e8a2629 --- /dev/null +++ b/_devtools/Projet.kxf @@ -0,0 +1,229 @@ + + + + 192 + 154 + 633 + 292 + Form1 + clBtnFace + DEFAULT_CHARSET + clWindowText + -13 + Segoe UI + + Menu1 + False + True + -1798701056 + 256 + 1.04 + False + False + False + False + -1 + 1 + 0 + 1 + + 96 + 15 + + + + + 586 + 56 + 28 + 28 + Owner + MainMenu1 + + + + + + 5 + 9 + 70 + 23 + Utilisateur + DEFAULT_CHARSET + clWindowText + -16 + Segoe UI + + False + 0 + False + 1342308608 + 0 + + + + + + + 5 + 32 + 41 + 23 + Poste + DEFAULT_CHARSET + clWindowText + -16 + Segoe UI + + False + 1 + False + 1342308608 + 0 + + + + + + + 258 + 66 + 100 + 19 + Descriptif Rapide + 2 + False + 1342308609 + 0 + + + + + + + 81 + 7 + 418 + 23 + 3 + Input1 + 1342374016 + 512 + DockHeight + + + + + + 500 + 7 + 109 + 23 + 4 + Input1 + 1342374016 + 512 + DockHeight + + + + + + 50 + 32 + 294 + 23 + 5 + Input3 + 1342374016 + 512 + DockHeight + + + + + + 1 + 86 + 615 + 146 + + +
  • Edit1
  • +
    +
    + 6 + 1345523908 + 512 + +
    + +
    + + + 372 + 33 + 239 + 23 + 7 + Input3 + 1342374016 + 512 + DockHeight + + + + + + 346 + 34 + 25 + 23 + Tel. + DEFAULT_CHARSET + clWindowText + -16 + Segoe UI + + False + 8 + False + 1342308608 + 0 + + + + + + + + + + MenuItem2 + + + + + MenuItem4 + + + + + + + + MenuItem1 + + + + + MenuItem3 + + + + + + + +
    +
    \ No newline at end of file diff --git a/_devtools/README.md b/_devtools/README.md new file mode 100755 index 0000000..ce6d680 --- /dev/null +++ b/_devtools/README.md @@ -0,0 +1 @@ +Logiciel Tyleo Créé avec CNP \ No newline at end of file diff --git a/_devtools/Releases/.media b/_devtools/Releases/.media new file mode 100755 index 0000000..75a109f --- /dev/null +++ b/_devtools/Releases/.media @@ -0,0 +1,13 @@ +#cs ---------------------------------------------------------------------------- + + AutoIt Version : 3.3.14.5 + Auteur: Tyleo + + Fonction du Script : + Modèle de Script AutoIt. + +#ce ---------------------------------------------------------------------------- + +; Début du script - Ajouter votre code ci-dessous. +#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Icons\au3.ico) +