Jex Posted November 9, 2007 Share Posted November 9, 2007 For my Messenger script i need change listbox items text colors. Example if user online i need change that item text color green. I'm searched forum but not found. My scripts : Immediate Window , My Web Browser , Travian , Text Effect , Characters & Words per minute or second , Image Editor (ImageMagick) , Matrix style background effect ( Screensaver ) , Mail Sender , Protectlinks decoder and Rapidshare links checker , Fonts Fetcher , Region determine , Compare pictures , Gradient color box , Mouse Coordinates, Colors, Pixel Search things , Encrypt/Decrypt and embeding file in jpeg thing , Hard disk space monitor , Reflex game , Multiplayer Tic Tac Toe , WLM ( MSN ) personal message changer Link to comment Share on other sites More sharing options...
Siao Posted November 9, 2007 Share Posted November 9, 2007 (edited) I would suggest using ListView instead of ListBox, even if you don't need columns.With $LVS_NOCOLUMNHEADER style and other minor tweaks there would be no visual difference.This would allow you to easy change the text color of any listview item with GUICtrlSetColor.If you insist on using ListBox, I think the only way would be ownerdrawing it.You can start with this code. It wouldn't be hard to modify it, probably simply checking the online or whatever condition of the item in WM_DRAWITEM and setting the color withDLLCall("gdi32.dll","int","SetTextColor", "hwnd", $hDC, "int", $iColor). Edited November 9, 2007 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
Jex Posted November 9, 2007 Author Share Posted November 9, 2007 Thanks for your help but if im use "DLLCall("gdi32.dll","int","SetTextColor", "hwnd", $hDC, "int", $iColor)" all listbox items text color changing and i don't know how to "simply?" checking the online and setting the color with dllcall So i need use listview. My scripts : Immediate Window , My Web Browser , Travian , Text Effect , Characters & Words per minute or second , Image Editor (ImageMagick) , Matrix style background effect ( Screensaver ) , Mail Sender , Protectlinks decoder and Rapidshare links checker , Fonts Fetcher , Region determine , Compare pictures , Gradient color box , Mouse Coordinates, Colors, Pixel Search things , Encrypt/Decrypt and embeding file in jpeg thing , Hard disk space monitor , Reflex game , Multiplayer Tic Tac Toe , WLM ( MSN ) personal message changer Link to comment Share on other sites More sharing options...
Valuater Posted November 9, 2007 Share Posted November 9, 2007 another approach...XSkin is not requiredLocated here...http://www.autoitscript.com/forum/index.ph...st&p=4252628) Link to comment Share on other sites More sharing options...
Zedna Posted November 9, 2007 Share Posted November 9, 2007 More elegant would be use RichText control. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Jex Posted November 9, 2007 Author Share Posted November 9, 2007 I want if im double click nick in listbox or listview conversation window open. So i cant use editbox (http://www.autoitscript.com/forum/index.php?s=&showtopic=32494&view=findpost&p=425262 ) or RichText control. Now im changed my listbox codes to listview and i can use GUICtrlSetColor. Now i have another problem if im double click listview item how new gui will be open. ( I'm not searched yet double click thing because now im working on online/offline system in my messenger ) Thanks anyway My scripts : Immediate Window , My Web Browser , Travian , Text Effect , Characters & Words per minute or second , Image Editor (ImageMagick) , Matrix style background effect ( Screensaver ) , Mail Sender , Protectlinks decoder and Rapidshare links checker , Fonts Fetcher , Region determine , Compare pictures , Gradient color box , Mouse Coordinates, Colors, Pixel Search things , Encrypt/Decrypt and embeding file in jpeg thing , Hard disk space monitor , Reflex game , Multiplayer Tic Tac Toe , WLM ( MSN ) personal message changer Link to comment Share on other sites More sharing options...
Jex Posted November 9, 2007 Author Share Posted November 9, 2007 (edited) _GUICtrlListView_DeleteItem function have problem expandcollapse popup#include <GUIConstants.au3> #include <GuiListView.au3> $Width = 170 $Height = 250 $Form = GUICreate("FLEXY", $Width, $Height, -1, -1, BitOR($WS_POPUP, $WS_BORDER)) $Close = GUICtrlCreateLabel("X", $Width - 15, 0, 11, 20) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetCursor(-1, 0) $Formtitle = GUICtrlCreateLabel(" " & " (Online)", 0, 4, @DesktopWidth, 20, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $Formtitlebackground = GUICtrlCreateGraphic(0, 0, @DesktopWidth, 22) GUICtrlSetBkColor(-1, 0x000000) $List = GUICtrlCreateListView ( "col1", 0, 23, $Width, 215, $LVS_NOCOLUMNHEADER) $MenuItem = GUICtrlCreateMenu("Menu") $MenuItem1 = GUICtrlCreateMenuItem("Add user", $MenuItem) $MenuItem2 = GUICtrlCreateMenuItem("Delete user", $MenuItem) $MenuItem3 = GUICtrlCreateMenuItem("Save users", $MenuItem) $Separator1 = GUICtrlCreateMenuItem("", $MenuItem, 2) $MenuItem4 = GUICtrlCreateMenuItem("Exit", $MenuItem) GUISetState(@SW_SHOW, $Form) $Data = "!List||admin[]admin 3[]admin2[]flexy 123" If StringInStr($Data, "!List||") Then $Friendlist = StringSplit($Data, "||", 1) $Friendlist2 = StringSplit($Friendlist[2], "[]", 1) ;$Onlinelist = StringSplit($Friendlist[4], "***", 1) Dim $Listbox[UBound($Friendlist2) ] For $i = 1 To UBound($Friendlist2) - 1 If $Friendlist2[$i] <> "" Then GUICtrlCreateListViewItem ($Friendlist2[$i], $List) EndIf Next EndIf While 1 $msg = GUIGetMsg() If $msg = $Close Then Exit If $msg = $MenuItem2 Then $Count = _GUICtrlListView_GetSelectedIndices ($List) MsgBox("","",$Count) _GUICtrlListView_DeleteItem ($List, $Count) ;_GUICtrlListView_DeleteItem ($List, 2) <-- If im write number working true.. EndIf WEnd That not my real client just im crop for find what is wrong but i think that function have bug? Edit: I'm solved my problem now working Edit: That working: _GUICtrlListView_DeleteItem ($List, 2) But that not work: $Count = _GUICtrlListView_GetSelectedIndices ($List) MsgBox("","",$Count) _GUICtrlListView_DeleteItem ($List, 2) Msgbox saying true count but already not delete item i can't understand what is wrong? Edited November 9, 2007 by Jex My scripts : Immediate Window , My Web Browser , Travian , Text Effect , Characters & Words per minute or second , Image Editor (ImageMagick) , Matrix style background effect ( Screensaver ) , Mail Sender , Protectlinks decoder and Rapidshare links checker , Fonts Fetcher , Region determine , Compare pictures , Gradient color box , Mouse Coordinates, Colors, Pixel Search things , Encrypt/Decrypt and embeding file in jpeg thing , Hard disk space monitor , Reflex game , Multiplayer Tic Tac Toe , WLM ( MSN ) personal message changer Link to comment Share on other sites More sharing options...
Valuater Posted November 9, 2007 Share Posted November 9, 2007 (edited) Try this While 1 ;wait a sec... doesnt work 8) Edited November 9, 2007 by Valuater Link to comment Share on other sites More sharing options...
Jex Posted November 9, 2007 Author Share Posted November 9, 2007 (edited) _GUICtrlListView_DeleteItem ($List,_GUICtrlListView_SetItemSelected ($List, 1)) Deleting index 1. Not selected item. Edit : _GUICtrlListView_DeleteItem ($List, _GUICtrlListView_GetItemSelected($List, 1)) Deleting first item. Not selected item... I'm for that reason using listbox instead listview Edited November 9, 2007 by Jex My scripts : Immediate Window , My Web Browser , Travian , Text Effect , Characters & Words per minute or second , Image Editor (ImageMagick) , Matrix style background effect ( Screensaver ) , Mail Sender , Protectlinks decoder and Rapidshare links checker , Fonts Fetcher , Region determine , Compare pictures , Gradient color box , Mouse Coordinates, Colors, Pixel Search things , Encrypt/Decrypt and embeding file in jpeg thing , Hard disk space monitor , Reflex game , Multiplayer Tic Tac Toe , WLM ( MSN ) personal message changer Link to comment Share on other sites More sharing options...
Siao Posted November 9, 2007 Share Posted November 9, 2007 (edited) I suggest you use handles instead of control IDs when working with these functions. Other than that, you really need to read the manual. About return value of functions. _GUICtrlListView_GetSelectedIndices returns string or array. When you pass string "2" to GuiCtrlSendMsg (that happens when you call _GUICtrlListView_DeleteItem with control ID of listview) it doesn't work. When you pass it to _SendMessage wrapper (that happens if you call _GUICtrlListView_DeleteItem with handle of listview), it works. Edited November 9, 2007 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
Valuater Posted November 9, 2007 Share Posted November 9, 2007 (edited) Got it.... expandcollapse popup#include <GUIConstants.au3> #include <GuiListView.au3> #include <array.au3> $Width = 170 $Height = 250 $Form = GUICreate("FLEXY", $Width, $Height, -1, -1, BitOR($WS_POPUP, $WS_BORDER)) $MenuItem = GUICtrlCreateMenu("Menu") $MenuItem1 = GUICtrlCreateMenuItem("Add user", $MenuItem) $MenuItem2 = GUICtrlCreateMenuItem("Delete user", $MenuItem) $MenuItem3 = GUICtrlCreateMenuItem("Save users", $MenuItem) $Separator1 = GUICtrlCreateMenuItem("", $MenuItem, 2) $MenuItem4 = GUICtrlCreateMenuItem("Exit", $MenuItem) $Close = GUICtrlCreateLabel("X", $Width - 15, 0, 11, 20) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetCursor(-1, 0) $Formtitle = GUICtrlCreateLabel(" " & " (Online)", 0, 4, @DesktopWidth, 20, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $Formtitlebackground = GUICtrlCreateGraphic(0, 0, @DesktopWidth, 22) GUICtrlSetBkColor(-1, 0x000000) $List = GUICtrlCreateListView("test", 0, 23, $Width, 215, $LVS_NOCOLUMNHEADER) _GUICtrlListView_InsertColumn ($List, 0, "Column 1", $Width - 10) GUISetState(@SW_SHOW, $Form) $Data = "!List||admin[]admin 3[]admin2[]flexy 123" If StringInStr($Data, "!List||") Then $Friendlist = StringSplit($Data, "||", 1) $Friendlist2 = StringSplit($Friendlist[2], "[]", 1) ;$Onlinelist = StringSplit($Friendlist[4], "***", 1) Dim $Listbox[UBound($Friendlist2) ] For $i = 1 To UBound($Friendlist2) - 1 If $Friendlist2[$i] <> "" Then _GUICtrlListView_AddItem ($List, $Friendlist2[$i], 0) EndIf Next EndIf While 1 $msg = GUIGetMsg() If $msg = $Close Or $msg = $MenuItem4 Then Exit If $msg = $MenuItem2 Then $selected = _GUICtrlListView_GetSelectedIndices($List, 1) If IsArray($selected) Then _GUICtrlListView_DeleteItem ($List,$selected[1]) EndIf WEnd 8) EDIT: added error checking If IsArray($selected) Then _GUICtrlListView_DeleteItem ($List,$selected[1]) Edited November 9, 2007 by Valuater Link to comment Share on other sites More sharing options...
Jex Posted November 9, 2007 Author Share Posted November 9, 2007 Very thanks Valuater My scripts : Immediate Window , My Web Browser , Travian , Text Effect , Characters & Words per minute or second , Image Editor (ImageMagick) , Matrix style background effect ( Screensaver ) , Mail Sender , Protectlinks decoder and Rapidshare links checker , Fonts Fetcher , Region determine , Compare pictures , Gradient color box , Mouse Coordinates, Colors, Pixel Search things , Encrypt/Decrypt and embeding file in jpeg thing , Hard disk space monitor , Reflex game , Multiplayer Tic Tac Toe , WLM ( MSN ) personal message changer Link to comment Share on other sites More sharing options...
Valuater Posted November 9, 2007 Share Posted November 9, 2007 Very thanks Valuater Welcome!!8) Link to comment Share on other sites More sharing options...
Jex Posted November 10, 2007 Author Share Posted November 10, 2007 First i want sort listview later check user online or offline and later i want change color to red or green but my script dont work? ( By the way sorry for my bad English but i think at least understandable :"> ) expandcollapse popup#include <GUIConstants.au3> #include <GuiListView.au3> #include <array.au3> $Width = 170 $Height = 250 $Form = GUICreate("FLEXY", $Width, $Height, -1, -1, BitOR($WS_POPUP, $WS_BORDER)) $MenuItem = GUICtrlCreateMenu("Menu") $MenuItem1 = GUICtrlCreateMenuItem("TEST!", $MenuItem) $MenuItem2 = GUICtrlCreateMenuItem("Delete user", $MenuItem) $MenuItem3 = GUICtrlCreateMenuItem("Save users", $MenuItem) $Separator1 = GUICtrlCreateMenuItem("", $MenuItem, 2) $MenuItem4 = GUICtrlCreateMenuItem("Exit", $MenuItem) $Close = GUICtrlCreateLabel("X", $Width - 15, 0, 11, 20) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetCursor(-1, 0) $Formtitle = GUICtrlCreateLabel(" " & " (Online)", 0, 4, @DesktopWidth, 20, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $Formtitlebackground = GUICtrlCreateGraphic(0, 0, @DesktopWidth, 22) GUICtrlSetBkColor(-1, 0x000000) $List = GUICtrlCreateListView("test", 0, 23, $Width, 215, $LVS_NOCOLUMNHEADER) _GUICtrlListView_InsertColumn ($List, 0, "Column 1", $Width - 45) GUISetState(@SW_SHOW, $Form) $Data = "!List||flexy 123[]admin 3[]admin2[]admin" If StringInStr($Data, "!List||") Then $Friendlist = StringSplit($Data, "||", 1) $Friendlist2 = StringSplit($Friendlist[2], "[]", 1) ;$Onlinelist = StringSplit($Friendlist[4], "***", 1) Dim $Listbox[UBound($Friendlist2) ] For $i = 1 To UBound($Friendlist2) - 1 If $Friendlist2[$i] <> "" Then _GUICtrlListView_AddItem ($List, $Friendlist2[$i], 0) EndIf Next EndIf While 1 $msg = GUIGetMsg() If $msg = $Close Or $msg = $MenuItem4 Then Exit ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;| If $msg = $MenuItem1 Then Local $Index[_GUICtrlListView_GetItemCount($List) + 1] Global $B_DESCENDING[_GUICtrlListView_GetColumnCount ($List)] _GUICtrlListView_SimpleSort ($List, $B_DESCENDING, 0) For $i = 1 To _GUICtrlListView_GetItemCount($List) $Index[$i] = _GUICtrlListView_MapIndexToID($List, $i - 1) Next GUICtrlSetColor($Index[1], 0xFFFF00) GUICtrlSetColor($Index[2], 0xFF0000) GUICtrlSetColor($Index[3], 0x00FF00) GUICtrlSetColor($Index[4], 0x0000FF) EndIf ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;| WEnd My scripts : Immediate Window , My Web Browser , Travian , Text Effect , Characters & Words per minute or second , Image Editor (ImageMagick) , Matrix style background effect ( Screensaver ) , Mail Sender , Protectlinks decoder and Rapidshare links checker , Fonts Fetcher , Region determine , Compare pictures , Gradient color box , Mouse Coordinates, Colors, Pixel Search things , Encrypt/Decrypt and embeding file in jpeg thing , Hard disk space monitor , Reflex game , Multiplayer Tic Tac Toe , WLM ( MSN ) personal message changer Link to comment Share on other sites More sharing options...
Jex Posted November 12, 2007 Author Share Posted November 12, 2007 (edited) Finally im managed change listview colors but now i can't add small images.Like that :My code imagelist create part :$List = GUICtrlCreateListView(" ", 0, 23, $Width, 215, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOCOLUMNHEADER)) $Image = _GUIImageList_Create () _GUIImageList_Add ($Image, _GUICtrlListView_CreateSolidBitMap (GUICtrlGetHandle($List), 0xFF0000, 10, 10)) _GUIImageList_Add ($Image, _GUICtrlListView_CreateSolidBitMap (GUICtrlGetHandle($List), 0x00FF00, 10, 10)) _GUIImageList_Add ($Image, _GUICtrlListView_CreateSolidBitMap (GUICtrlGetHandle($List), 0x0000FF, 10, 10)) _GUICtrlListView_SetImageList ($List, $Image, 1) Edited November 12, 2007 by Jex My scripts : Immediate Window , My Web Browser , Travian , Text Effect , Characters & Words per minute or second , Image Editor (ImageMagick) , Matrix style background effect ( Screensaver ) , Mail Sender , Protectlinks decoder and Rapidshare links checker , Fonts Fetcher , Region determine , Compare pictures , Gradient color box , Mouse Coordinates, Colors, Pixel Search things , Encrypt/Decrypt and embeding file in jpeg thing , Hard disk space monitor , Reflex game , Multiplayer Tic Tac Toe , WLM ( MSN ) personal message changer Link to comment Share on other sites More sharing options...
Zedna Posted November 14, 2007 Share Posted November 14, 2007 Finally im managed change listview colors but now i can't add small images. Like that : My code imagelist create part : $List = GUICtrlCreateListView(" ", 0, 23, $Width, 215, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOCOLUMNHEADER)) $Image = _GUIImageList_Create () _GUIImageList_Add ($Image, _GUICtrlListView_CreateSolidBitMap (GUICtrlGetHandle($List), 0xFF0000, 10, 10)) _GUIImageList_Add ($Image, _GUICtrlListView_CreateSolidBitMap (GUICtrlGetHandle($List), 0x00FF00, 10, 10)) _GUIImageList_Add ($Image, _GUICtrlListView_CreateSolidBitMap (GUICtrlGetHandle($List), 0x0000FF, 10, 10)) _GUICtrlListView_SetImageList ($List, $Image, 1) What OS do you use? There is bug in GUICtrlListView_CreateSolidBitMap() on WIN98. I noticed some bug there but I didn't have much time to debug it more deeply yet. Resources UDF ResourcesEx UDF AutoIt Forum Search 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