Morthawt Posted May 8, 2015 Share Posted May 8, 2015 I am trying to make a button that is right-aligned starting from the top that is multi-line. But when ever I alter a colour of the button the formatting goes away.I expected the following script to have a button that is top-right aligned and coloured grey and white. But... the only way it actually is top-right aligned is if I comment out both the text and background colour lines.Am I missing something?#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 217, 69, 192, 124) $Button1 = GUICtrlCreateButton("This Is A Button" & @LF & "That You Can Push", 24, 8, 171, 49, BitOR($BS_RIGHT, $BS_TOP, $BS_MULTILINE)) GUICtrlSetBkColor(-1, 0x333333) GUICtrlSetColor(-1, 0xffffff) GUICtrlSetFont(-1, 5, 0, 0, "MS Sans Serif", 5) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
guinness Posted May 8, 2015 Share Posted May 8, 2015 Search Trac (bug tracker) and you will notice there is no work around using AutoIt for colouring buttons. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Morthawt Posted May 8, 2015 Author Share Posted May 8, 2015 Well if it is listed in a bug tracker, hopefully it will get fixed. Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 8, 2015 Moderators Share Posted May 8, 2015 Morthawt,No chance - it is buried far too deeply in the core code as explained in the ticket.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...
Morthawt Posted May 8, 2015 Author Share Posted May 8, 2015 Well thank you for crushing my very soul Melba23 lol. Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
guinness Posted May 8, 2015 Share Posted May 8, 2015 (edited) Well if it is listed in a bug tracker, hopefully it will get fixed.Well thank you for crushing my very soul Melba23 lol.I am going to crush it even further! =)Regardless of it being a bug, colouring buttons to signify the result of a particular action or to grab the user's attention is bad UI choice, as it's inconsistent with the overall design of GUIs in Windows and therefore unfamiliar for a user. How many times have you seen an OK button in a GUI coloured green? I know I haven't.Source: https://msdn.microsoft.com/en-us/library/windows/desktop/ff728831(v=vs.85).aspx#the_basic_principles_of_proper_ui Edited May 8, 2015 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
UEZ Posted May 8, 2015 Share Posted May 8, 2015 (edited) Maybe you can use images or icons for your buttons (also mono color images). Or even you can use GDI+ for creating the images (text + color properly formated). Edited May 8, 2015 by UEZ 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...
Moderators Melba23 Posted May 8, 2015 Moderators Share Posted May 8, 2015 Morthawt,Sorry about your soul. On the few occasions I have felt the need to colour highlight buttons, I have just placed them over a label as I explain in this thread - there are some suggestions from others in there as well.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...
Morthawt Posted May 9, 2015 Author Share Posted May 9, 2015 Well I highlight buttons based on relevance of the keywords in certain web pages. I have a column of buttons on the left of the screen and one on the right, each button copying different things into the clipboard and lighting up based on keywords. So I wanted to have the left side of the screen have left aligned buttons and the right one right aligned. But it never works with any colour settings which is really strange and apparently an unfixable bug. ;( Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
UEZ Posted May 9, 2015 Share Posted May 9, 2015 I extend the _GDIPlus_BtnCtrlSetBgColorSolid function.expandcollapse popup#include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> #include <GDIPlus.au3> _GDIPlus_Startup() $hGUI = GUICreate("Test", 500, 500) $iButton1 = GUICtrlCreateButton("Button1", 10, 40, 80, 30, $BS_BITMAP) $hHBitmap1 = _GDIPlus_BtnCtrlSetBgColorSolid($hGUI, $iButton1, 0x00FF00, "", "Arial", 8.5, 0xFF000000, 0) $iButton2 = GUICtrlCreateButton("Button1", 10, 80, 80, 30, $BS_LEFT) GUICtrlSetFont(-1, 8.5, 400, 1, "Arial", 5) $iButton3 = GUICtrlCreateButton("Button2", 400, 40, 80, 30, $BS_BITMAP) $hHBitmap2 = _GDIPlus_BtnCtrlSetBgColorSolid($hGUI, $iButton3, 0x00FF00, "", "Arial", 8.5, 0xFF000000, 2) $iButton4 = GUICtrlCreateButton("Button2", 400, 80, 80, 30, $BS_Right) GUICtrlSetFont(-1, 8.5, 400, 1, "Arial", 5) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hHBitmap1) _WinAPI_DeleteObject($hHBitmap2) _GDIPlus_Shutdown() GUIDelete() Exit Case $iButton1, $iButton2, $iButton3, $iButton4 MsgBox(0, "", "button triggered") EndSwitch WEnd Func _GDIPlus_BtnCtrlSetBgColorSolid($hGUI, $iCtrlID, $iColor, $sText = "", $sFont = "Arial", $fSize = 8.5, $iFontColor = 0xFF000000, $iFontAlign = 1, $iFontLineAlign = 1) ;coded by UEZ 2014 Local $aSize = ControlGetPos($hGUI, "", $iCtrlID) If @error Then Return SetError(1, 0, 0) If $sText = "" Then $sText = ControlGetText($hGUI, "", $iCtrlID) Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($aSize[2], $aSize[3]) Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) Local Const $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $iColor) _GDIPlus_GraphicsFillRect($hGfx, 2, 2, $aSize[2] - 4, $aSize[3] - 4, $hBrush) _GDIPlus_GraphicsSetTextRenderingHint($hGfx, 5) _GDIPlus_GraphicsSetSmoothingMode($hGfx, 2) Local Const $hFormat = _GDIPlus_StringFormatCreate() Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local Const $hFont = _GDIPlus_FontCreate($hFamily, $fSize) Local $iDX = 0, $iDY = 0 Switch $iFontAlign Case 0 $iDX = 2 Case 2 $iDX = -2 EndSwitch Switch $iFontLineAlign Case 0 $iDY = 2 Case 2 $iDY = -2 EndSwitch Local Const $tLayout = _GDIPlus_RectFCreate($iDX, $iDY, $aSize[2], $aSize[3]) Local Const $hBrush_Font = _GDIPlus_BrushCreateSolid($iFontColor) _GDIPlus_StringFormatSetAlign($hFormat, $iFontAlign) _GDIPlus_StringFormatSetLineAlign($hFormat, $iFontLineAlign) _GDIPlus_GraphicsDrawStringEx($hGfx, $sText, $hFont, $tLayout, $hFormat, $hBrush_Font) Local Const $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BrushDispose($hBrush_Font) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_BrushDispose($hBrush) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($iCtrlID), $BM_SETIMAGE, 0, $hHBitmap)) Return $hHBitmap EndFunc 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