Popular Post kurtykurtyboy Posted February 4, 2019 Popular Post Share Posted February 4, 2019 (edited) GuiFlatButton is a UDF to easily create regular buttons with different colors for background, foreground, border, hover, focus, etc.. This started as an effort to change the background color of a button and eventually grew into a full UDF. If you've looked around forums for changing button background colors, you have probably noticed that each proposed workaround has its own set of issues/side-effects. The answers usually circle back to 'use ownerdrawn buttons' and 'not worth it'. Well, now it is possible for anyone to easily create ownerdrawn buttons - totally worth it! Some issues with other workarounds such as drawing with GDI+ or using a colored label as a 'button': Not 'real' buttons so you lose built-in functionality that windows gives to buttons Messy / inefficient code in the main while loop to check for mouse position Slow to respond to click, paint, etc... Having to deal with GUIRegisterMsg messages Not straight-forward to implement GuiFlatButton is not a workaround; it is a technique to respond to Windows' built-in owner-drawn button events. With minimal effort, we can now create true simple colored buttons. The idea is to create an owner-drawn button using GUICtrlCreateButton then subclass the GUI and controls to handle the button-specific events to paint it however we want. This UDF magically does all of this for us! No need to worry about event handling or main while loop logic. How to use It couldn't be any easier! Simply create a new button using the familiar syntax. This creates an ownerdrawn button with default colors. $mybutton1 = GuiFlatButton_Create("Button 1", 78, 20, 120, 40) If you want to change the background and text colors: GuiFlatButton_SetBkColor(-1, 0x5555FF) GuiFlatButton_SetColor(-1, 0xFFFFFF) Advanced Usage Set background/text/border all at once GuiFlatButton_SetColors(-1, 0x0000FF, 0xFFFFFF, 0x9999FF) Set ALL colors for ALL button states! (normal, focus, hover, selected) Local $aColorsEx = [0x0000FF, 0xFFFFFF, -2, 0x4444FF, 0xFFFFFF, 0xAAAAFF, 0x6666FF, 0xFFFFFF, 0xCCCCFF, 0x0000EE, 0xFFFFFF, 0x7777EE] GuiFlatButton_SetColorsEx(-1, $aColorsEx) Set default colors to apply to any future buttons ;set colors GuiFlatButton_SetDefaultColors(0x0000FF, 0xFFFFFF, 0x9999FF) ;create buttons $mybutton1 = GuiFlatButton_Create("Button 1", 12, 20, 120, 40) $mybutton2 = GuiFlatButton_Create("Button 2", 143, 20, 120, 40) Set ALL color defaults ;set colors Local $aColorsEx = [0x0000FF, 0xFFFFFF, -2, 0x4444FF, 0xFFFFFF, 0xAAAAFF, 0x6666FF, 0xFFFFFF, 0xCCCCFF, 0x0000EE, 0xFFFFFF, 0x7777EE] GuiFlatButton_SetDefaultColorsEx($aColorsEx) ;create buttons $mybutton1 = GuiFlatButton_Create("Button 1", 12, 20, 120, 40) $mybutton2 = GuiFlatButton_Create("Button 2", 143, 20, 120, 40) Available Functions Spoiler ; GuiFlatButton_Create ................: Create a new flat button ; GuiFlatButton_Read ..................: Read the display text of the button ; GuiFlatButton_SetData ...............: Set the display text of the button ; GuiFlatButton_SetBkColor ............: Set button background color ; GuiFlatButton_SetColor ..............: Set button foreground/text color ; GuiFlatButton_SetColors .............: Set background, foreground, border colors at the same time ; GuiFlatButton_SetColorsEx ...........: Set background, foreground, border colors for ALL states at the same time ; GuiFlatButton_SetDefaultColors ......: Set background, foreground, border colors to be used for all future buttons ; GuiFlatButton_SetDefaultColorsEx ....: Set background, foreground, border colors for ALL states to be used for all future buttons ; GuiFlatButton_GetState ..............: Get the state of the button ; GuiFlatButton_SetState ..............: Set the state of the button ; GuiFlatButton_Delete ................: Remove subclasses and delete the control ; GuiFlatButton_SetPos ................: Changes the position of a control ; GuiFlatButton_GetPos ................: Get the position of a control Simple Example expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include "GuiFlatButton.au3" Example() ;GUI with one button Func Example() Local $hGUI, $mybutton1 $hGUI = GUICreate("GuiFlatButton Ex0", 275, 120) GUISetBkColor(0x333333) Local $idLabel = GUICtrlCreateLabel("Click the button", 10, 100, 150, 30) GUICtrlSetColor(-1, 0xFFFFFF) ;create new button then set the background and foreground colors $mybutton1 = GuiFlatButton_Create("Button 1" & @CRLF & "Line 2", 78, 20, 120, 40, $BS_MULTILINE) GuiFlatButton_SetBkColor(-1, 0x5555FF) GuiFlatButton_SetColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW, $hGUI) Local $i = 0 Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $mybutton1 $i += 1 GUICtrlSetData($idLabel, $i) ConsoleWrite($i & @CRLF) EndSwitch Sleep(10) WEnd GUIDelete() EndFunc ;==>Example Menu/Toolbar Example expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include "GuiFlatButton.au3" Example() ;Example GUI with toolbar Func Example() Local $hGUI, $idLabel, $aButtons, $iTbSize $hGUI = GUICreate("GuiFlatButton Ex2", 300, 200) GUISetBkColor(0x444444) $idLabel = GUICtrlCreateLabel("Click a button", 10, 180, 150, 30) GUICtrlSetColor(-1, 0xFFFFFF) $aButtons = createToolbar() $iTbSize = UBound($aButtons) GUISetState(@SW_SHOW, $hGUI) Local $i = 0 Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $aButtons[0] To $aButtons[$iTbSize - 1] ConsoleWrite("1") GUICtrlSetData($idLabel, GuiFlatButton_Read($iMsg)) EndSwitch Sleep(10) WEnd GUIDelete() EndFunc ;==>Example Func createToolbar() Local $aButtons[6] Local $bkColor = 0x777777 Local $textColor = 0xFFFFFF Local $borderColor = 0x999999 Local $aBtnClrs[12] = [0x777777, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT, 0x888888, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT, 0x999999, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT, 0x666666, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT] For $i = 0 To UBound($aButtons) - 1 $aButtons[$i] = GuiFlatButton_Create("B" & $i, $i * 50, 0, 50, 17) GuiFlatButton_SetColorsEx($aButtons[$i], $aBtnClrs) Next Return $aButtons EndFunc ;==>createToolbar Icon Example You can even easily add icons to your buttons -- just create a new button and send it an icon! expandcollapse popup#include <GDIPlus.au3> #include "GuiFlatButton.au3" Example() ;buttons with Icon images Func Example() ;get images for demonstration _GDIPlus_Startup() ;initialize GDI+ Local $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 258, 24, 24) ;extract the 'Save' icon Local $hBitmap = _GDIPlus_BitmapCreateFromHICON($hIcon) ;Create Bitmap from Icon (for demonstration) Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ;Create HBitmap from Bitmap _GDIPlus_BitmapDispose($hBitmap) ;dispose the bitmap _GDIPlus_Shutdown() ;done with GDI+ Local $hGUI = GUICreate("GuiFlatButton Ex5", 255, 400) GUISetBkColor(0xEEEEEE) ;set default colors of future buttons Local $aColorsEx = _ [0xE2E5E8, 0X000000, 0x888888, _ ; normal : Background, Text, Border 0xE2E5E8, 0X000000, 0x333333, _ ; focus : Background, Text, Border 0xE8E8E8, 0X000000, 0x666666, _ ; hover : Background, Text, Border 0xDDDDDD, 0X000000, 0xAAAAAA] ; selected : Background, Text, Border GuiFlatButton_SetDefaultColorsEx($aColorsEx) ;normal button with icon $label1 = GUICtrlCreateLabel( "$BS_TOOLBUTTON -->", 5, 10) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) Local $mybutton1 = GuiFlatButton_Create("Save", 130, 5, 50, 48, $BS_TOOLBUTTON) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybutton1), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align top Local $mybuttonT = GuiFlatButton_Create("Top", 5, 65, 120, 55, $BS_TOP) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonT), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align top-left Local $mybuttonTL = GuiFlatButton_Create("Top-Left", 5, 125, 120, 55, BITOR($BS_TOP, $BS_LEFT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonTL), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align top-right Local $mybuttonTR = GuiFlatButton_Create("Top-Right", 5, 185, 120, 55, BITOR($BS_TOP, $BS_RIGHT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonTR), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align left Local $mybuttonL = GuiFlatButton_Create("Left", 5, 245, 120, 55, $BS_LEFT) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonL), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align bottom Local $mybuttonB = GuiFlatButton_Create("Bottom", 130, 65, 120, 55, $BS_BOTTOM) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonB), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align bottom-left Local $mybuttonBL = GuiFlatButton_Create("Bottom-Left", 130, 125, 120, 55, BITOR($BS_BOTTOM, $BS_LEFT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonBL), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align bottom-right Local $mybuttonBR = GuiFlatButton_Create("Bottom-Right", 130, 185, 120, 55, BITOR($BS_BOTTOM, $BS_RIGHT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonBR), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align right Local $mybuttonR = GuiFlatButton_Create("Right", 130, 245, 120, 55, $BS_RIGHT) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonR), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) GuiFlatButton_SetState($mybuttonR, $GUI_DISABLE ) ;disabled Local $mybuttonDisable = GuiFlatButton_Create("Disabled", 130, 310, 120, 55, $BS_TOOLBUTTON) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonDisable), $BM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)) GuiFlatButton_SetState($mybuttonDisable, $GUI_DISABLE ) ;clean up! _WinAPI_DestroyIcon( $hIcon ) _WinAPI_DeleteObject( $hHBitmap ) GUISetState(@SW_SHOW, $hGUI) Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch Sleep(10) WEnd GUIDelete() EndFunc ;==>Example I'm sure there are some use-cases I've forgotten, so feedback is welcome! Download the latest UDF and several more examples:GuiFlatButton_20220919.zip (1,121) Update 2022-09-19 Added update from 05/25 back in after it was accidentally removed Update 2022-09-01 Added $BS_MULTILINE button style Added ellipses when text is longer than the button Fixed compatibility with Opt("MustDeclareVars", 1) Update 2022-05-25 Fixed issue, buttons disappear when a GUI containing a child window with WS_EX_MDICHILD extended style is moved Update 2022-05-24 Fixed issue releasing subclassing when GUI is deleted but program is not closed Fixed occasional white background flicker Added function GuiFlatButton_GetPos Update 2021-01-02 Fixed bug, not drawing correctly after deleting GUI with GUIDelete() Fixed bug, changing default colors changed all buttons, even previously created buttons Made some internal functions more efficient Update 2019-04-14 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 Update 2019-02-09 Added 2 new functions to set the button colors globally for all future buttons. GuiFlatButton_SetDefaultColors GuiFlatButton_SetDefaultColorsEx Credits to: Melba23 (UDF template) LarsJ (general subclassing code) 4ggr35510n (TrackMouseEvent example) binhnx (disable dragging with $WS_EX_CONTROLPARENT) GUIRegisterMsg in AutoIt Help (owner-draw button example) funkey (_WinAPI_DrawState example) Edited September 20, 2022 by kurtykurtyboy Updates LarsJ, FrancescoDiMuro, mumpel and 14 others 13 4 Link to comment Share on other sites More sharing options...
careca Posted February 4, 2019 Share Posted February 4, 2019 Looks great! Should be part of the default button creation. 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 More sharing options...
qwert Posted February 5, 2019 Share Posted February 5, 2019 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 More sharing options...
qwert Posted February 7, 2019 Share Posted February 7, 2019 (edited) 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? Edited February 7, 2019 by qwert Link to comment Share on other sites More sharing options...
kurtykurtyboy Posted February 10, 2019 Author Share Posted February 10, 2019 @qwert Your wish is my command! Added functions to set default colors: GuiFlatButton_SetDefaultColors GuiFlatButton_SetDefaultColorsEx See first post for how to use. A new example was added to the zip as well. Link to comment Share on other sites More sharing options...
qwert Posted February 10, 2019 Share Posted February 10, 2019 Thanks for adding those. I haven't had time to delve into the code, so can you spot the reason these two buttons come up with different colors? In my simple way of thinking, the two create calls would use the same colors. Link to comment Share on other sites More sharing options...
kurtykurtyboy Posted February 11, 2019 Author Share Posted February 11, 2019 It looks like the first button has focus so it is using your focus color. Try hitting the tab key a few times to switch between the buttons. Link to comment Share on other sites More sharing options...
qwert Posted February 11, 2019 Share Posted February 11, 2019 Well, yes, I can see that now. While you're still looking at this, can you tell me where the white border is coming from (on a hover), when I've set all the border colors to 0x000000? Link to comment Share on other sites More sharing options...
kurtykurtyboy Posted February 12, 2019 Author Share Posted February 12, 2019 Silly mistake on my part. Updated zip in first post. I hope you don't mind I used your array format in the example. Link to comment Share on other sites More sharing options...
qwert Posted February 12, 2019 Share Posted February 12, 2019 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 More sharing options...
kurtykurtyboy Posted April 15, 2019 Author Share Posted April 15, 2019 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 Link to comment Share on other sites More sharing options...
qwert Posted April 17, 2019 Share Posted April 17, 2019 Quote GuiFlatButton_20190414.zip 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 More sharing options...
Jazzer Posted November 3, 2019 Share Posted November 3, 2019 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 More sharing options...
Jazzer Posted November 6, 2019 Share Posted November 6, 2019 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 More sharing options...
r2du-soft Posted August 1, 2020 Share Posted August 1, 2020 hi, i have a problem whit new button style after use GUIDelete() expandcollapse popup;----------------------------------------------------- ;#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 More sharing options...
r2du-soft Posted August 1, 2020 Share Posted August 1, 2020 5 hours ago, r2du-soft said: hi, i have a problem whit new button style after use GUIDelete() expandcollapse popup;----------------------------------------------------- ;#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: expandcollapse popup;----------------------------------------------------- ;#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 More sharing options...
kurtykurtyboy Posted January 2, 2021 Author Share Posted January 2, 2021 @r2du-soft Your 2 issues should be resolved with the update in the original post. Thanks for the feedback! Link to comment Share on other sites More sharing options...
supersonic Posted January 29, 2021 Share Posted January 29, 2021 @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 More sharing options...
qwert Posted April 22, 2021 Share Posted April 22, 2021 @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. Parsix 1 Link to comment Share on other sites More sharing options...
Parsix Posted April 24, 2021 Share Posted April 24, 2021 (edited) 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 April 24, 2021 by Parsix Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now