2Radon Posted April 17, 2014 Share Posted April 17, 2014 This is frustrating. $btnCreds = GUICtrlCreateButton("Set Username And Password", 40, 90, 250, 25) ; Creates it light gray and nicely rectangular with sharp corners GUICtrlSetBkColor($btnCreds, $COLOR_RED) ; Changes the button's style to a MS Paint rounded corner rectangle. Ugh! GUICtrlSetStyle($btnCreds, $GUI_SS_DEFAULT_BUTTON) ; Found this in forums, and it changes the color back to the default light gray also. ;( Please save my button! Link to comment Share on other sites More sharing options...
mLipok Posted April 17, 2014 Share Posted April 17, 2014 Your Repro script is incomplete. here is working repro: expandcollapse popup#include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 300, 200) ; Create a button control. Local $iNotepad = GUICtrlCreateButton("Run Notepad", 120, 170, 85, 25) Local $iClose = GUICtrlCreateButton("Close", 210, 170, 85, 25) #Region REPRO $btnCreds = GUICtrlCreateButton("Set Username And Password", 40, 90, 250, 25) ; Creates it light gray and nicely rectangular with sharp corners GUICtrlSetBkColor($btnCreds, $COLOR_RED) ; Changes the button's style to a MS Paint rounded corner rectangle. Ugh! GUICtrlSetStyle($btnCreds, $GUI_SS_DEFAULT_BUTTON) ; Found this in forums, and it changes the color back to the default light gray also. ;( #EndRegion REPRO ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) Local $iPID = 0 ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $iClose ExitLoop Case $iNotepad ; Run Notepad with the window maximized. $iPID = Run("notepad.exe", "", @SW_SHOWMAXIMIZED) EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) ; Close the Notepad process using the PID returned by Run. If $iPID Then ProcessClose($iPID) EndFunc ;==>Example And indeed there is "strange" behavior maybe a bug. but solution is really easy: first use GUICtrlSetStyle and after that use GUICtrlSetBkColor Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
2Radon Posted April 17, 2014 Author Share Posted April 17, 2014 Thanks, but it is the same. Use GUICtrlSetStyle and then GUICtrlSetBkColor and it will set the style back to the ugly one instantly, so that is not a solution. Link to comment Share on other sites More sharing options...
mLipok Posted April 17, 2014 Share Posted April 17, 2014 so what you want to achieve with this: GUICtrlSetStyle($btnCreds, $GUI_SS_DEFAULT_BUTTON) ; Found this in forums, and it changes the color back to the default light gray also. ;( Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
mLipok Posted April 17, 2014 Share Posted April 17, 2014 look here: GUICtrlCreateButton To combine styles with the default style use BitOR( $GUI_SS_DEFAULT_BUTTON, newstyle, ... ). Now i think this is not strange but intentional=standard behavior. Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
2Radon Posted April 17, 2014 Author Share Posted April 17, 2014 look here: GUICtrlCreateButton Now i think this is not strange but intentional=standard behavior. Nay man, I think you ain't getting it. GUICtrlSetBkColour changes the style, as you see in this image. Link to comment Share on other sites More sharing options...
mLipok Posted April 17, 2014 Share Posted April 17, 2014 (edited) It seems to its behavior belongs to Windows Settings or you here is my results: Can you show me your results form my repro. EDIT: Did you use any othere styles to build your GUI ? EIDT2: remember to change order: GUICtrlSetStyle($btnCreds, $GUI_SS_DEFAULT_BUTTON) ; Found this in forums, and it changes the color back to the default light gray also. ;( GUICtrlSetBkColor($btnCreds, $COLOR_RED) ; Changes the button's style to a MS Paint rounded corner rectangle. Ugh! Edited April 17, 2014 by mLipok Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
2Radon Posted April 17, 2014 Author Share Posted April 17, 2014 No it is simply the buttons, there is no other case or scene or anything at all!! Whatever you do BkColor wants it to look so ugly! In your picture it is the same, no need to show. Look at your repro button and look at my button picture I posted above. compare the way the top button looks to the way bottom buttons look. BkColor makes it stylistically look like that. CtrlStyle resets the color back to default while BkColor sets the style to that ugly one. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 17, 2014 Moderators Share Posted April 17, 2014 2Radon,Be careful because colouring buttons can cause problems - such as the button being captured by the {ENTER} key and, as you have noticed, all styles being removed. This is due to a bug deep in the AutoIt core code which will not be fixed until that code is rewritten (i.e. probably never). My advice - do not colour buttons. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
KaFu Posted April 17, 2014 Share Posted April 17, 2014 As close as I could get ... expandcollapse popup; http://www.autoitscript.com/forum/topic/113811-guictrlbutton-settextcolor/ ; based on post by Yashied #include <GUIButton.au3> #include <GUIImageList.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> GUICreate('MyGUI', 200, 100) GUICtrlCreateButton('OK', 65, 10, 70, 23) GUICtrlCreateButton('OK', 65, 40, 70, 23) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlCreateButton('', 65, 70, 70, 23) _GUICtrlButton_SetTextBkColor(-1, 'OK', 0xFF0000, 0x00FF00) GUISetState() Do Until GUIGetMsg() = -3 Func _GUICtrlButton_SetTextBkColor($iCtrlID, $sText, $iTextColor, $iBkColor) Local $hWnd, $hTheme, $hImageList, $hBitmap, $hBack, $hDC, $hMemDC, $hSrcDC, $tRect, $pRect, $Width, $Height, $Prev, $Flags = BitOR($DT_CENTER, $DT_SINGLELINE, $DT_VCENTER) $hWnd = GUICtrlGetHandle($iCtrlID) If Not $hWnd Then Return 0 EndIf $hTheme = DllCall('uxtheme.dll', 'ptr', 'OpenThemeData', 'hwnd', $hWnd, 'wstr', 'BUTTON') If (@error) Or (Not $hTheme[0]) Then GUICtrlSetColor($iCtrlID, $iTextColor) GUICtrlSetData($iCtrlID, $sText) Return 1 EndIf $Width = _WinAPI_GetClientWidth($hWnd) $Height = _WinAPI_GetClientHeight($hWnd) $hImageList = _GUIImageList_Create($Width - 8, $Height - 8, 4, 4) $tRect = DllStructCreate('int[4]') DllStructSetData($tRect, 1, -4, 1) DllStructSetData($tRect, 1, -4, 2) DllStructSetData($tRect, 1, $Width - 4, 3) DllStructSetData($tRect, 1, $Height - 4, 4) $pRect = DllStructGetPtr($tRect) $hDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hSrcDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $Width - 8, $Height - 8) ;$hBack = _WinAPI_CreateCompatibleBitmap($hDC, $Width - 8, $Height - 8) $hBack = _WinAPI_CreateSolidBitmap($hWnd, $iBkColor, $Width - 8, $Height - 8) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_SelectObject($hSrcDC, $hBack) _WinAPI_SelectObject($hMemDC, _SendMessage($hWnd, $WM_GETFONT)) _WinAPI_SetTextColor($hMemDC, BitOR(BitAND($iTextColor, 0x00FF00), BitShift(BitAND($iTextColor, 0x0000FF), -16), BitShift(BitAND($iTextColor, 0xFF0000), 16))) _WinAPI_SetBkMode($hMemDC, $TRANSPARENT) ; PBS_NORMAL, PBS_HOT, PBS_PRESSED, PBS_DISABLED, PBS_DEFAULTED For $i = 1 To 5 $Prev = _WinAPI_SelectObject($hMemDC, $hBitmap) DllCall('uxtheme.dll', 'int', 'DrawThemeBackground', 'ptr', $hTheme[0], 'hwnd', $hSrcDC, 'int', 4, 'int', $i, 'ptr', $pRect, 'ptr', 0) _WinAPI_BitBlt($hMemDC, 0, 0, $Width - 8, $Height - 8, $hSrcDC, 0, 0, $MERGECOPY) If $i = 4 Then DllCall('uxtheme.dll', 'int', 'DrawThemeText', 'ptr', $hTheme[0], 'hwnd', $hMemDC, 'int', 1, 'int', 4, 'wstr', $sText, 'int', -1, 'dword', $Flags, 'dword', 0, 'ptr', $pRect) Else _WinAPI_DrawText($hMemDC, $sText, $tRect, $Flags) EndIf _WinAPI_SelectObject($hMemDC, $Prev) _GUIImageList_Add($hImageList, $hBitmap) Next ; PBS_HOT (Stylus Hot) _GUIImageList_SetImageCount($hImageList, 6) _GUIImageList_Copy($hImageList, 1, 5) _WinAPI_DeleteDC($hMemDC) _WinAPI_DeleteDC($hSrcDC) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hBack) DllCall('uxtheme.dll', 'int', 'CloseThemeData', 'ptr', $hTheme[0]) $Prev = _GUICtrlButton_GetImageList($hWnd) If $Prev[0] Then _GUIImageList_Destroy($Prev[0]) EndIf GUICtrlSetData($iCtrlID, '') If Not _GUICtrlButton_SetImageList($hWnd, $hImageList, 4) Then _GUIImageList_Destroy($hImageList) Return 0 EndIf Return 1 EndFunc ;==>_GUICtrlButton_SetTextBkColor Norm73 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
UEZ Posted April 17, 2014 Share Posted April 17, 2014 (edited) Here a version using GDI+ (works only on 3.3.10.0+ versions):expandcollapse popup#include <ButtonConstants.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global Const $hGUI = GUICreate("Colored Buttons using GDI+", 600, 300) Global Const $iBtn1 = GUICtrlCreateButton("Default", 125, 75, 150, 150) GUICtrlSetFont(-1, 14.5, 400, 0, "Arial", 4) Global Const $iBtn2 = GUICtrlCreateButton("", 325, 75, 150, 150, $BS_BITMAP) Global Const $hBmp = _GDIPlus_BtnCtrlSetBgColor($iBtn2, "Colored", 146, 146) GUISetState() Do Switch GUIGetMsg() Case $iBtn1 MsgBox(0, "Test", "Default button has been pressed") Case $iBtn2 MsgBox(0, "Test", "Colored button has been pressed") Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hBmp) _GDIPlus_Shutdown() GUIDelete() Exit EndSwitch Until False Func _GDIPlus_BtnCtrlSetBgColor($iBtn, $sText, $iW, $iH, $iStartColor = 0xF0FFFFF0, $iEndColor = 0x4040FF40, $sFontSize = 14, $sFont = "Arial") ;coded by UEZ 2014 Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;~ _GDIPlus_GraphicsSetSmoothingMode($hGfx, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetTextRenderingHint($hGfx, 4) Local Const $hBrush_Bg = _GDIPlus_LineBrushCreate($iW / 8, 0, $iW / 2, $iH - $iH / 8, $iStartColor, $iEndColor, 1) ;~ _GDIPlus_LineBrushSetLinearBlend($hBrush_Bg, 0.15, 0.999) _GDIPlus_GraphicsFillRect($hGfx, 0, 0, $iW, $iH, $hBrush_Bg) Local $hBrush_Txt = _GDIPlus_BrushCreateSolid(0xFF000000) Local $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $hFont = _GDIPlus_FontCreate($hFamily, $sFontSize) Local $hLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH) Local $hStringFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hStringFormat, 1) _GDIPlus_StringFormatSetLineAlign($hStringFormat, 1) _GDIPlus_GraphicsDrawStringEx($hGfx, $sText, $hFont, $hLayout, $hStringFormat, $hBrush_Txt) Local Const $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($iBtn), $BM_SETIMAGE, $IMAGE_BITMAP, $hGDIBitmap)) _GDIPlus_BrushDispose($hBrush_Bg) _GDIPlus_BrushDispose($hBrush_Txt) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_StringFormatDispose($hStringFormat) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BitmapDispose($hBitmap) Return $hGDIBitmap EndFuncBr,UEZ Edited April 17, 2014 by UEZ Zedna 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ 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