Jump to content

GuiFlatButton UDF : Change Colors of Regular Buttons


kurtykurtyboy
 Share

Recommended Posts

Looks great! Should be part of the default button creation. :P

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Impressive!   Thanks for this.

The only "improvement" that comes to mind is to add a two-button example that makes clear (by direct comparison) the capabilities of GuiFlatButton_SetColorsEx ... and maybe include a couple of commented-out alternative lines that show some of the more effective uses you've tested.

 

Link to comment
Share on other sites

In working with the UDF, I've settled on a default (my default) look for buttons that will work on many screens. As a test, I've edited the Button_Create function as follows:

;fill the array with the default values
    $aGuiFlatButton[$i][0] = $i
    $aGuiFlatButton[$i][4] = False
    $aGuiFlatButton[$i][5] = 13357056               ; bk color
    $aGuiFlatButton[$i][6] = 0x00000000             ; color of text
    $aGuiFlatButton[$i][17] = $sText
    For $j = 7 To 16
        $aGuiFlatButton[$i][$j] = -1
    Next

Should I be looking at a different method for this? Have you thought of adding some sort of SetTheme function that can predefine several of the settings prior to any Button_Create calls?

5c5bb8c5e31e1_DefaultButton.PNG.10d6eb4d7966c633e51c86473886a6ce.PNG

Edited by qwert
Link to comment
Share on other sites

Quote

I hope you don't mind

Not at all.  Thanks for keeping at it.  This is going to be a very useful UDF!  Styles and such on websites have led users to expect this sort of thing ... which Autoit scripts are now going to be able to deliver.

Link to comment
Share on other sites

Quote

I specifically want to commend you for placing the file date in the file name. Most files are posted without any indication. (Worse, of course, is posting a later version down in the thread!)

I've lost count of the number of times I'd had to figure out which version of a zip or au3 was the latest.

Thanks for your good work. These are nice features.

 

Link to comment
Share on other sites

  • 6 months later...

Hello,

I have two questions, 

Is there anyway to set and manipulate the text on buttons? (Font, size and position)

When it comes to icons on buttons, can I use an ico file (and can the position be set)? Does it only support icons? 
If you can give some examples, I would be grateful,

Thank you again for this beautiful work.

 

Link to comment
Share on other sites

On 4/15/2019 at 4:33 AM, kurtykurtyboy said:

First post updated.

Changes include:
Fixed bug, not showing pressed down state when clicking rapidly
Added Icon/Bitmap support!
Added function GuiFlatButton_SetPos to change the position and/or size of a button

Hello,

I have two questions, 

Is there anyway to set and manipulate the text on buttons? (Font, size and position)

When it comes to icons on buttons, can I use an ico file (and can the position be set)? Does it only support icons? 
If you can give some examples, I would be grateful,

Thank you again for this beautiful work.

Link to comment
Share on other sites

  • 8 months later...

hi, i have a problem whit new button style after use GUIDelete() 

;-----------------------------------------------------
;#includes
#include-once
#include <MsgBoxConstants.au3>
#include <GuiFlatButton.au3>
;-----------------------------------------------------


_Main()


Func _Main()
    $GUI_Main = GUICreate("Main " & FileGetVersion(@ScriptFullPath), 200, 200, 10, 10, $WS_POPUPWINDOW)
    $BTN_Show_Page_2 = GuiFlatButton_Create("Show Page 2", 10, 10, 100, 38)
    Local $Param_1[12] = [0x0096a1, 0xFFFFFF, 0x0096a1, 0x0096a1, 0xFFFFFF, 0x0096a1, 0xE43D35, 0xFFFFFF, 0xE43D35, 0xFF3D35, 0xFFFFFF, 0xFF3D35]
    GuiFlatButton_SetColorsEx($BTN_Show_Page_2, $Param_1)
    GUISetState()
    While 1
        $iMsg_Main = GUIGetMsg()
        Select
            Case $iMsg_Main = $GUI_EVENT_CLOSE 
                Continueloop
            Case $iMsg_Main = $BTN_Show_Page_2
                GUIDelete()
                _Page_2()
                ExitLoop
        EndSelect
    WEnd
EndFunc


Func _Page_2()
    $GUI_HWNDPARENT2 = GUICreate("Page 2 " & FileGetVersion(@ScriptFullPath), 200, 200, 80, 80-1, $WS_POPUPWINDOW)
    $BTN_Exit = GuiFlatButton_Create("Exit", 10, 10, 100, 38)
    Local $Param_2[12] = [0x0096a1, 0xFFFFFF, 0x0096a1, 0x0096a1, 0xFFFFFF, 0x0096a1, 0xE43D35, 0xFFFFFF, 0xE43D35, 0xFF3D35, 0xFFFFFF, 0xFF3D35]
    GuiFlatButton_SetColorsEx($BTN_Exit, $Param_2)
    GUISetState()
    While 1
        $iMsg_Main = GUIGetMsg()
        Select
            Case $iMsg_Main = $GUI_EVENT_CLOSE 
                Continueloop
            Case $iMsg_Main = $BTN_Exit 
                Exit
        EndSelect
    WEnd
EndFunc

 

after show page 2 the new button style Loss of color !!!

i most use GUIDelete() and afterthat  open another form

what is the problem???

 

Link to comment
Share on other sites

5 hours ago, r2du-soft said:

hi, i have a problem whit new button style after use GUIDelete() 

;-----------------------------------------------------
;#includes
#include-once
#include <MsgBoxConstants.au3>
#include <GuiFlatButton.au3>
;-----------------------------------------------------


_Main()


Func _Main()
    $GUI_Main = GUICreate("Main " & FileGetVersion(@ScriptFullPath), 200, 200, 10, 10, $WS_POPUPWINDOW)
    $BTN_Show_Page_2 = GuiFlatButton_Create("Show Page 2", 10, 10, 100, 38)
    Local $Param_1[12] = [0x0096a1, 0xFFFFFF, 0x0096a1, 0x0096a1, 0xFFFFFF, 0x0096a1, 0xE43D35, 0xFFFFFF, 0xE43D35, 0xFF3D35, 0xFFFFFF, 0xFF3D35]
    GuiFlatButton_SetColorsEx($BTN_Show_Page_2, $Param_1)
    GUISetState()
    While 1
        $iMsg_Main = GUIGetMsg()
        Select
            Case $iMsg_Main = $GUI_EVENT_CLOSE 
                Continueloop
            Case $iMsg_Main = $BTN_Show_Page_2
                GUIDelete()
                _Page_2()
                ExitLoop
        EndSelect
    WEnd
EndFunc


Func _Page_2()
    $GUI_HWNDPARENT2 = GUICreate("Page 2 " & FileGetVersion(@ScriptFullPath), 200, 200, 80, 80-1, $WS_POPUPWINDOW)
    $BTN_Exit = GuiFlatButton_Create("Exit", 10, 10, 100, 38)
    Local $Param_2[12] = [0x0096a1, 0xFFFFFF, 0x0096a1, 0x0096a1, 0xFFFFFF, 0x0096a1, 0xE43D35, 0xFFFFFF, 0xE43D35, 0xFF3D35, 0xFFFFFF, 0xFF3D35]
    GuiFlatButton_SetColorsEx($BTN_Exit, $Param_2)
    GUISetState()
    While 1
        $iMsg_Main = GUIGetMsg()
        Select
            Case $iMsg_Main = $GUI_EVENT_CLOSE 
                Continueloop
            Case $iMsg_Main = $BTN_Exit 
                Exit
        EndSelect
    WEnd
EndFunc

 

after show page 2 the new button style Loss of color !!!

i most use GUIDelete() and afterthat  open another form

what is the problem???

 

also i use from GuiFlatButton_SetDefaultColorsEx but i need chage a button style blue and blue light and another button gree and red but all buttons set a style color like:

;-----------------------------------------------------
;#includes
#include-once
#include <MsgBoxConstants.au3>
#include <GuiFlatButton.au3>
;-----------------------------------------------------


_Main()

Func _Main()
    ;------------
    $GUI_Main = GUICreate("Main " & FileGetVersion(@ScriptFullPath), 200, 200, 10, 10, $WS_POPUPWINDOW)
    ;------------
    ;Green | Red
    Local $aColorsEx = _
    [0x0096a1, 0xFFFFFF, 0x0096a1, _    ; normal    : Background, Text, Border
     0x0096a1, 0xFFFFFF, 0x0096a1, _    ; focus     : Background, Text, Border
     0xE43D35, 0xFFFFFF, 0xE43D35, _    ; hover     : Background, Text, Border
     0xFF3D35, 0xFFFFFF, 0xFF3D35]      ; selected  : Background, Text, Border
    GuiFlatButton_SetDefaultColorsEx($aColorsEx)
    ;---
    $BTN_Show_Page_2 = GuiFlatButton_Create("Show Page 2", 10, 10, 100, 38)
    ;------------
    GUISetState()
    While 1
        $iMsg_Main = GUIGetMsg()
        Select
            Case $iMsg_Main = $GUI_EVENT_CLOSE 
                Continueloop
            Case $iMsg_Main = $BTN_Show_Page_2
                GUIDelete()
                _Page_2()
                ExitLoop
        EndSelect
    WEnd
EndFunc

Func _Page_2()

    $GUI_HWNDPARENT2 = GUICreate("Page 2 " & FileGetVersion(@ScriptFullPath), 200, 200, 80, 80-1, $WS_POPUPWINDOW)
    ;------------
    ;Green | Red
    Local $aColorsEx = _
    [0x0096a1, 0xFFFFFF, 0x0096a1, _    ; normal    : Background, Text, Border
     0x0096a1, 0xFFFFFF, 0x0096a1, _    ; focus     : Background, Text, Border
     0xE43D35, 0xFFFFFF, 0xE43D35, _    ; hover     : Background, Text, Border
     0xFF3D35, 0xFFFFFF, 0xFF3D35]      ; selected  : Background, Text, Border
    GuiFlatButton_SetDefaultColorsEx($aColorsEx)
    ;---
    $BTN_Back = GuiFlatButton_Create("Back", 10, 10, 100, 38,1)
    ;------------
    ;Blue | BlueLight
    Local $aColorsEx = _
    [0x4aa5d2, 0xFFFFFF, 0x4aa5d2, _    ; normal    : Background, Text, Border
     0x4aa5d2, 0xFFFFFF, 0x4aa5d2, _    ; focus     : Background, Text, Border
     0x4aa5d2, 0xFFFFFF, 0x4aa5d2, _    ; hover     : Background, Text, Border
     0x54aedb, 0xFFFFFF, 0x54aedb]      ; selected  : Background, Text, Border
    GuiFlatButton_SetDefaultColorsEx($aColorsEx)
    ;---
    $BTN_Exit_2 = GuiFlatButton_Create("Exit 2", 20, 60, 100, 38,1)
    ;------------
    GUISetState()
    While 1
        $iMsg_Main = GUIGetMsg()
        Select
            Case $iMsg_Main = $GUI_EVENT_CLOSE 
                Continueloop
            Case $iMsg_Main = $BTN_Back
                GUIDelete()
                _Main()
                MsgBox(0, "", "END 1")
                ExitLoop
            Case $iMsg_Main = $BTN_Exit_2
                Exit
        EndSelect
    WEnd
EndFunc

 

how  can fix this?

Link to comment
Share on other sites

  • 4 weeks later...

@kurtykurtyboy

Greate UDF, thank you!

I have found some minor flaws:

"D:\_\AUTOIT\Include\kurtykurtyboy\GuiFlatButton_20210102\GuiFlatButton.au3" (152) : ==> Variable used without being declared.:
$buttonID = GUICtrlCreateButton("", 0, 0, $w, $h)
^ ERROR

"D:\_\AUTOIT\Include\kurtykurtyboy\GuiFlatButton_20210102\GuiFlatButton.au3" (157) : ==> Variable used without being declared.:
$idIndex = GuiFlatButton_FindControlId($buttonID)
^ ERROR

"D:\_\AUTOIT\Include\kurtykurtyboy\GuiFlatButton_20210102\GuiFlatButton.au3" (181) : ==> Variable used without being declared.:
$aColors = $aGuiFlatButton[0][3]
^ ERROR

... if using Opt("MustDeclareVars", 1) .

Would be great if you could fix it.

Link to comment
Share on other sites

  • 2 months later...

@kurtykurtyboy

I hope it's not too late to add to this thread, but I've encountered a problem using flat buttons that I just can't get a handle on.

Under some circumstances, the flat buttons disappear from the GUI I'm using them on. (Minimizing and restoring the GUI doesn't being them back.)

It's so rare that I haven't been able to isolate a cause. (I suspect it might be related to my use of SplashTextOn windows as overlays.) And the flat buttons work fine, up until they go away. Once they're gone, they're completely gone ... hovering ... tooltips ... everything.

MSDN has a detailed description of window type here ... but it's hard to follow how all the variations might interact.

So my questions are: 1) should my main GUI be created as a Layered window? and 2) are flat buttons considered Child windows?

Those answers will help me decipher what might be happening.

Thanks in advance for help.

Link to comment
Share on other sites

On 4/22/2021 at 7:00 PM, qwert said:

@kurtykurtyboy

I hope it's not too late to add to this thread, but I've encountered a problem using flat buttons that I just can't get a handle on.

Under some circumstances, the flat buttons disappear from the GUI I'm using them on. (Minimizing and restoring the GUI doesn't being them back.)

It's so rare that I haven't been able to isolate a cause. (I suspect it might be related to my use of SplashTextOn windows as overlays.) And the flat buttons work fine, up until they go away. Once they're gone, they're completely gone ... hovering ... tooltips ... everything.

MSDN has a detailed description of window type here ... but it's hard to follow how all the variations might interact.

So my questions are: 1) should my main GUI be created as a Layered window? and 2) are flat buttons considered Child windows?

Those answers will help me decipher what might be happening.

Thanks in advance for help.

 

I have same problem With GuiFlatButton in MetroGUI or Layerd Windows 

Edited by Parsix
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...