FinalVersion Posted May 12, 2009 Share Posted May 12, 2009 I want to change the font color etc of the list box "text" not the background color. Is this possible? [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] Link to comment Share on other sites More sharing options...
exodius Posted May 12, 2009 Share Posted May 12, 2009 (edited) Do GuiCtrlSetColor on each ListViewItem as you create them.#include <GUIConstants.au3> #include <WindowsConstants.au3> GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES) GUISetBkColor(0x00E0FFFF) ; will change background color $listview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150);,$LVS_SORTDESCENDING) $item1 = GUICtrlCreateListViewItem("item2|col22|col23", $listview) $item2 = GUICtrlCreateListViewItem("............item1|col12|col13", $listview) GUICtrlSetColor (-1, 0x0000FF) $item3 = GUICtrlCreateListViewItem("item3|col32|col33", $listview) GUICtrlSetColor (-1, 0xFF0000) GUISetState() Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE Edited May 12, 2009 by exodius Link to comment Share on other sites More sharing options...
Yashied Posted May 12, 2009 Share Posted May 12, 2009 Do GuiCtrlSetColor on each ListViewItem as you create them. #include <GUIConstants.au3> #include <WindowsConstants.au3> GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES) GUISetBkColor(0x00E0FFFF) ; will change background color $listview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150);,$LVS_SORTDESCENDING) $item1 = GUICtrlCreateListViewItem("item2|col22|col23", $listview) $item2 = GUICtrlCreateListViewItem("............item1|col12|col13", $listview) GUICtrlSetColor (-1, 0x0000FF) $item3 = GUICtrlCreateListViewItem("item3|col32|col33", $listview) GUICtrlSetColor (-1, 0xFF0000) GUISetState() Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSEYou use ListView. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
exodius Posted May 12, 2009 Share Posted May 12, 2009 Totally overlooked that he said ListBox, although the principal is the exact same. Here's how to do it with a Listbox: #include <GUIConstants.au3> GUICreate("My GUI list") ; will create a dialog box that when displayed is centered $mylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97) GUICtrlSetColor (-1, 0xFF0000) GUICtrlSetData (-1, "Test1") GUICtrlSetData (-1, "Test2") GUICtrlSetData (-1, "Test3") GUICtrlSetData (-1, "Test4") GUICtrlSetData (-1, "Test5") GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() WEnd Link to comment Share on other sites More sharing options...
FinalVersion Posted May 13, 2009 Author Share Posted May 13, 2009 Totally overlooked that he said ListBox, although the principal is the exact same. Here's how to do it with a Listbox: #include <GUIConstants.au3> GUICreate("My GUI list") ; will create a dialog box that when displayed is centered $mylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97) GUICtrlSetColor (-1, 0xFF0000) GUICtrlSetData (-1, "Test1") GUICtrlSetData (-1, "Test2") GUICtrlSetData (-1, "Test3") GUICtrlSetData (-1, "Test4") GUICtrlSetData (-1, "Test5") GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() WEnd Thank you. [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] Link to comment Share on other sites More sharing options...
Mcgruff30 Posted August 18, 2009 Share Posted August 18, 2009 Do GuiCtrlSetColor on each ListViewItem as you create them. #include <GUIConstants.au3> #include <WindowsConstants.au3> GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES) GUISetBkColor(0x00E0FFFF) ; will change background color $listview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150);,$LVS_SORTDESCENDING) $item1 = GUICtrlCreateListViewItem("item2|col22|col23", $listview) $item2 = GUICtrlCreateListViewItem("............item1|col12|col13", $listview) GUICtrlSetColor (-1, 0x0000FF) $item3 = GUICtrlCreateListViewItem("item3|col32|col33", $listview) GUICtrlSetColor (-1, 0xFF0000) GUISetState() Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE Ok I'm a newbie when it comes to AutoIT and am struggling with this one. I've got the concept of setting the text color when you are adding each individual item in the manner you outline above; however, the problem I'm running into is I'm adding my listview items via the _GUICtrlListView_AddArray function so I can't figure out how to change the color of the text for each array when I add them. Is there a way to do this? Thanks. Link to comment Share on other sites More sharing options...
Viper2025 Posted December 21, 2012 Share Posted December 21, 2012 Ahhhhh.... can someone answer the question? about changing the font and Color of a LISTBOX? NOT a 'ListView' and not NOT a 'List' please... A LISTBOX!! For some reason GUICtrlSetFont and GUICtrlSetColor doesn't work for a LISTBOX.... It does work fine for listview and list controls. Link to comment Share on other sites More sharing options...
BrewManNH Posted December 22, 2012 Share Posted December 22, 2012 Why would you resurrect a 3+ year old thread? GUICtrlsetColor works just fine for a list box, but it will recolor all the contents of the listbox, not just one line at a time. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Viper2025 Posted December 22, 2012 Share Posted December 22, 2012 (edited) Why would you resurrect a 3+ year old thread? GUICtrlsetColor works just fine for a list box, but it will recolor all the contents of the listbox, not just one line at a time. Sorry BrewMan I didn't mean to come across as and ass. I had made a stupid mistake in my code and came here looking for answers. I posted on this thread because the question was very specific to a "list box" and was not answered specifically about a list box but referred to other controls. These forum is my bible for Autoit when the manual(which is excellent BTW) doesn't answer my question. As long as I'm actually posting I should thank a few hundred of the folks that have answered questions on this forum and helped me out over the years.. THANKS VERY MUCH! Why did I post on a 3 year old thread? Because 3 year old threads and some much older have helped me greatly over the years and when I do a search I want as few threads to read through as possible. Because it is old doesn’t mean it can’t help. We really don't need another thread, for poor slobs like me to read.. Just need this one answered correctly and specific to both changing the font and changing the text color of a list box. So Allow me to contribute… Examples of working code when your trying to figure out a problem are invaluable. #include #include #include $Debug_LB = False ; Check ClassName being passed to ListBox functions, set to True and use a handle to another control to see it work _Main() Func _Main() Local $hListBox ; Create GUI GUICreate("List Box Begin Update", 400, 296) $hListBox = GUICtrlCreateList("", 2, 2, 396, 296) GUICtrlSetColor (-1, 0xFF0000) GUICtrlSetFont(-1,15,500) GUISetState() ; Add files _GUICtrlListBox_BeginUpdate($hListBox) _GUICtrlListBox_ResetContent($hListBox) _GUICtrlListBox_InitStorage($hListBox, 100, 4096) _GUICtrlListBox_Dir($hListBox, @WindowsDir & "\win*.exe") _GUICtrlListBox_AddFile($hListBox, @WindowsDir & "\notepad.exe") _GUICtrlListBox_Dir($hListBox, "", $DDL_DRIVES) _GUICtrlListBox_Dir($hListBox, "", $DDL_DRIVES, False) _GUICtrlListBox_EndUpdate($hListBox) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main Edited December 22, 2012 by Viper2025 Link to comment Share on other sites More sharing options...
BrewManNH Posted December 22, 2012 Share Posted December 22, 2012 Still not seeing your problem, that code works just fine, the text is red, and the font size is 15 point. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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