nyke0 Posted August 27, 2014 Share Posted August 27, 2014 #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 350, 250, -1, -1) $ListView1 = GUICtrlCreateListView("Header|Header|Header", 0, 0, 350, 250) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GuiCtrlCreateListViewItem('Black|Black|Black',$ListView1) GuiCtrlCreateListViewItem('Black|GREEN?|Black',$ListView1) GuiCtrlCreateListViewItem('Black|Black|Black',$ListView1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Can I color the single font color (not the background) to green or other color than all the other ones? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 27, 2014 Moderators Share Posted August 27, 2014 nyke0,You can make the whole line green by doing this:GuiCtrlCreateListViewItem('Black|GREEN?|Black',$ListView1) GUICtrlSetColor(-1, 0x00FF00)If you want to colour just the single sub-item then you are into owner-drawn ListViews - search the forum, there are some good examples out there. 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...
mikell Posted August 27, 2014 Share Posted August 27, 2014 Very common question expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 350, 250, -1, -1) $ListView1 = GUICtrlCreateListView("Header|Header|Header", 0, 0, 350, 250) GuiCtrlCreateListViewItem('Black|Black|Black',$ListView1) GuiCtrlCreateListViewItem('Black|GREEN?|Black',$ListView1) GuiCtrlCreateListViewItem('Black|Black|Black',$ListView1) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iCode = DllStructGetData($tNMHDR, "Code") $hListView = GuiCtrlGetHandle($ListView1) Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $iDrawStage = DllStructGetData($tCustDraw, "dwDrawStage") If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW Local $iSubItem = DllStructGetData($tCustDraw, "iSubItem") Local $iItem = DllStructGetData($tCustDraw, "dwItemSpec") Local $iColor If $iItem = 1 and $iSubItem = 1 Then $iColor = RGB2BGR(0x00cc00) DllStructSetData($tCustDraw, "clrText", $iColor) Return $CDRF_NEWFONT EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func RGB2BGR($iColor) Return BitAND(BitShift(String(Binary($iColor)), 8), 0xFFFFFF) EndFunc ;==>RGB2BGR() Many possible additional features mentioned everywhere on the forum Link to comment Share on other sites More sharing options...
Adele Posted February 14, 2015 Share Posted February 14, 2015 Can we change color of the specified item without use the value returning from GuiCtrlCreateListViewItem()? Link to comment Share on other sites More sharing options...
kylomas Posted February 14, 2015 Share Posted February 14, 2015 (edited) If you mean the value populating the listview cell, then yes... expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 350, 250, -1, -1) $ListView1 = GUICtrlCreateListView("Header|Header|Header", 0, 0, 350, 250) GuiCtrlCreateListViewItem('Black|Black|Black',$ListView1) GuiCtrlCreateListViewItem('Black|xxxxx|Black',$ListView1) GuiCtrlCreateListViewItem('Black|Black|Black',$ListView1) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iCode = DllStructGetData($tNMHDR, "Code") $hListView = GuiCtrlGetHandle($ListView1) Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $iDrawStage = DllStructGetData($tCustDraw, "dwDrawStage") If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW Local $iSubItem = DllStructGetData($tCustDraw, "iSubItem") Local $iItem = DllStructGetData($tCustDraw, "dwItemSpec") Local $iColor If $iItem = 1 and $iSubItem = 1 Then $iColor = RGB2BGR(0xcc0000) DllStructSetData($tCustDraw, "clrText", $iColor) Return $CDRF_NEWFONT EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func RGB2BGR($iColor) Return BitAND(BitShift(String(Binary($iColor)), 8), 0xFFFFFF) EndFunc ;==>RGB2BGR() kylomas edit: Stick to one thread per question please. You asked the same question >here. If you are not getting a timely response (at least 24 hours) then open your own thread. Edited February 14, 2015 by kylomas czardas and Adele 2 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 14, 2015 Moderators Share Posted February 14, 2015 Adele,If you want to colour the whole line rather then just the subitem it is a bit simpler: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $hGUI = GUICreate("Test", 500, 500) $cListView = GUICtrlCreateListView("Header|Header|Header", 0, 0, 350, 250) GUICtrlCreateListViewItem('00|01|02', $cListView) GUICtrlCreateListViewItem('10|11|12', $cListView) GUICtrlCreateListViewItem('20|21|22', $cListView) GUISetState() GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMLISTVIEW, $iItem, $iCode, $cID $tNMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam) $iCode = DllStructGetData($tNMLISTVIEW, "Code") If $iCode = $NM_CLICK Then $iItem = DllStructGetData($tNMLISTVIEW, "Item") $cID = _GUICtrlListView_GetItemParam($cListView, $iItem) ; Autoit stores the ControlID in the item paramter GUICtrlSetColor($cID, 0xFF0000) EndIf EndFunc ;==>_WM_NOTIFYM23 Adele 1 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...
Adele Posted February 14, 2015 Share Posted February 14, 2015 kylomas, Melba23 they worked. Thank you. 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