marcsusy Posted January 19, 2015 Share Posted January 19, 2015 (edited) helloI adapted a script to change color items but does not work can someone help.Pleasemy script is as follows: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <FontConstants.au3> #include <WinAPI.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 438, 192, 124) $Button1 = GUICtrlCreateButton("Button1", 272, 264, 75, 25) $ListView1 = GUICtrlCreateListView("nº | col1 | col2 | col3 " , 72, 88, 474, 150, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 30) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 150) _GUICtrlListView_GetColumn($ListView1, 0) _GUICtrlListView_JustifyColumn($ListView1, 0, 2) _GUICtrlListView_GetColumn($ListView1, 1) _GUICtrlListView_JustifyColumn($ListView1, 1, 2) _GUICtrlListView_GetColumn($ListView1, 2) _GUICtrlListView_JustifyColumn($ListView1, 1, 0) _GUICtrlListView_GetColumn($ListView1, 3) _GUICtrlListView_JustifyColumn($ListView1, 1, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $Font1 = _WinAPI_CreateFont(14, 6, 0, 0, $FW_BOLD),$iItem Global $Font2 = _WinAPI_CreateFont(14, 6, 0, 0, $FW_BOLD, True) For $a = 1 to 200 IF Mod($a, 2) = 0 Then $Var = "stock " $Var1 = "not out" $Var2 = "Color Blue" Else $Var = "no stock" $Var1 = "exhausted" $Var2 = "Color Red" Endif GUICtrlCreateListViewItem($a &"|" &$Var&"|"&$Var1&"|"&$Var2, $ListView1) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 For $iItem = 0 to _GUICtrlListView_GetItemCount($ListView1) IF _GUICtrlListView_GetItemText($ListView1,$iItem,1) = "no stock" Then GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Endif Next _WinAPI_DeleteObject($Font1) _WinAPI_DeleteObject($Font2) 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") Switch $hWndFrom Case $ListView1 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, $hDC Switch $iItem Case 0 $hDC = DllStructGetData($tCustDraw, "hdc") $iColor = 0x5555DD _WinAPI_SelectObject($hDC, $Font1) DllStructSetData($tCustDraw, "clrText", $iColor) Return $CDRF_NEWFONT EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Edited January 19, 2015 by Melba23 Added code tags Link to comment Share on other sites More sharing options...
pcjunki Posted January 19, 2015 Share Posted January 19, 2015 maybe this? GUICtrlSetBkColor(-1,0x000080) Link to comment Share on other sites More sharing options...
reb Posted January 19, 2015 Share Posted January 19, 2015 Look here. '?do=embed' frameborder='0' data-embedContent>> REB MEASURE TWICE - CUT ONCE Link to comment Share on other sites More sharing options...
marcsusy Posted January 19, 2015 Author Share Posted January 19, 2015 pcjunki Thanks also serves me, but I want also to change the color of text in a subitem. Link to comment Share on other sites More sharing options...
funkey Posted January 19, 2015 Share Posted January 19, 2015 Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. 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