kk_lee69
发表于 2016-10-15 21:41:20
回复 15# tubaba
我也是 用虛擬列表的.............
kk_lee69
发表于 2016-10-15 21:43:37
回复 14# chzj589
能否 寫個簡單的變顏色範例 你現在可以做到的
然後我再改看看
kk_lee69
发表于 2016-10-15 21:57:21
回复 15# tubaba
請教一下這個變數 做啥用的 是啥內容
$RelativeEncryptCol
kk_lee69
发表于 2016-10-15 22:54:51
本帖最后由 kk_lee69 于 2016-10-15 22:56 编辑
回复 14# chzj589
弄好了 你看一下吧用上面的範例改的你應該 可以理解也感謝tubaba 兄 的舉例讓我了解的 前面一直搞不懂的邏輯
#include <Array.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <GuiImageList.au3>
Global $hListItem
Global $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo, $aHit, $hImage
Global $iColor, $iColorBk, $fChildGui = False
Local $path, $aFileList, $aNewList
$path = @ScriptDir
$aFileList = _FileListToArray($path, "*.txt")
Local $iI, $iTimer, $idListview
$Main_GUI = GUICreate("Test Management v1.0", 720, 300)
$idListview = GUICtrlCreateListView("", 15, 15, 550, 268)
$hListView = GUICtrlGetHandle($idListview)
$idComboBox = GUICtrlCreateCombo("", 600, 246, 90, 30)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
_GUICtrlListView_AddColumn($idListview, "Tester", 100)
_GUICtrlListView_AddColumn($idListview, "Test Item", 100)
_GUICtrlListView_AddColumn($idListview, "BMC IP", 100)
_GUICtrlListView_AddColumn($idListview, "Count", 60)
_GUICtrlListView_AddColumn($idListview, "Last Record Time", 150)
ReDim $aNewList
Local $sComboTxt = "所有"
$aNewList="A"
$aNewList="A1"
$aNewList="A29"
$aNewList="B1"
$aNewList="C1"
$aNewList="K"
$aNewList="DA1"
$aNewList="AKKK29"
$aNewList="BXX1"
$aNewList="Cee1"
$aNewList="AAA"
$aNewList="A1DDD"
$aNewList="A29"
$aNewList="B1"
$aNewList="C1"
GUICtrlSetData($idComboBox, $sComboTxt, "所有")
_GUICtrlListView_AddArray($idListview, $aNewList)
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
Case $idComboBox
$sComboRead = GUICtrlRead($idComboBox)
If $sComboRead == "所有" Then
_GUICtrlListView_DeleteAllItems($idListview)
_GUICtrlListView_AddArray($idListview, $aNewList)
Else
_GUICtrlListView_DeleteAllItems($idListview)
For $i = 0 To UBound($aNewList) - 1
If $aNewList[$i] == $sComboRead Then
GUICtrlCreateListViewItem($aNewList[$i] & "|" & $aNewList[$i] & "|" & $aNewList[$i] & "|" & $aNewList[$i] & "|" & $aNewList[$i], $idListview)
EndIf
Next
EndIf
EndSwitch
WEnd
;-----------------------------------------------------------------------------------------------------------
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
$hWndListView = $hListView
If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $LVN_ENDSCROLL
$tNMHDR = DllStructCreate("hwnd hWnd;uint cID;int code", $ilParam)
$hLV = HWnd(DllStructGetData($tNMHDR, "hWnd"))
_WinAPI_InvalidateRect($hLV)
Case $NM_DBLCLK
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$aHit = _GUICtrlListView_SubItemHitTest($hListView)
If $aHit < 0 Then Return $GUI_RUNDEFMSG
Switch $aHit
Case 7
$fChildGui = True
Child_GUI($aHit)
EndSwitch
Case $NM_CUSTOMDRAW
Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $ilParam)
Local $iDrawStage = DllStructGetData($tCustDraw, "dwDrawStage")
If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW
If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW
Local $iItem = DllStructGetData($tCustDraw, "dwItemSpec")
Local $iSubItem = DllStructGetData($tCustDraw, "iSubItem")
Local $sComboRead = GUICtrlRead($idComboBox)
If $iSubItem Then
IF _GUICtrlListView_GetItemText($hWndListView,$iItem,$iSubItem)="A29" Then
$iColor = 0x0000FF
$iColorBk = 0xC0C0C0
Else
$iColor = 0x000000
$iColorBk = 0xFFFFFF
EndIf
DllStructSetData($tCustDraw, "clrText", $iColor)
DllStructSetData($tCustDraw, "clrTextBk", $iColorBk)
EndIf
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
;-----------------------------------------------------------------------------------------------------------
Func Child_GUI($y)
; GUISetState(@SW_LOCK, $Main_GUI) ; uncommented changes behaviour
$APPTSTAT_GUI = GUICreate("", 230, 180, 560, 140)
GUISetState(@SW_SHOW, $APPTSTAT_GUI)
While 1
$msg2 = GUIGetMsg()
Switch $msg2
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
Sleep(50) ; why is this necessary? otherwise crashes
WEnd
GUIDelete($APPTSTAT_GUI)
GUISetState(@SW_RESTORE, $Main_GUI)
; GUISetState(@SW_UNLOCK, $Main_GUI); uncommented changes behaviour
EndFunc ;==>Child_GUI
ipmitool
发表于 2016-10-16 00:26:42
回复 19# kk_lee69
那如果只限定 BMC IP 這一欄符合A29才變紅色呢? 其他欄如果遇到A29不做變色 可以嗎?
kk_lee69
发表于 2016-10-16 02:15:12
回复 20# ipmitool
加AND $iSubItem=2
chzj589
发表于 2016-10-16 08:15:04
回复 21# kk_lee69
谢谢了!
关键是这一句判断找不到头绪,
If _GUICtrlListView_GetItemText($hWndListView, $iItem, $iSubItem) = "A29" Then
解决了,以后会用到。
AND $iSubItem=2,这一句要放在那里
chzj589
发表于 2016-10-16 09:06:44
回复 21# kk_lee69
chzj589
发表于 2016-10-16 09:07:41
回复 21# kk_lee69
AND $iSubItem=2,这一句可以不用
tubaba
发表于 2016-10-16 10:08:51
回复 18# kk_lee69
这是我从自己某个脚本复制过来的,那个变量跟本贴主题没有关系.就是一个着色的条件而已
ipmitool
发表于 2016-10-16 10:10:07
本帖最后由 ipmitool 于 2016-10-16 10:14 编辑
回复 24# chzj589
AND $iSubItem=2,这一句可以不用
那要怎麼用啊?
ipmitool
发表于 2016-10-16 10:38:58
回复 22# chzj589
_GUICtrlListView_GetItemText($hWndListView,$iItem,$iSubItem)="A29" AND $iSubItem=2 Then
這樣ok了, 謝謝馬蓋先大師及其他大師們的熱情幫忙!! 以解決嘍~
ipmitool
发表于 2016-10-16 11:28:05
本帖最后由 ipmitool 于 2016-10-16 11:32 编辑
回复 21# kk_lee69
拍謝, 我是想說在BMC IP欄位裡面, A29就白底綠字, 不是的話 就只設定BMC IP 欄位內其他內容為紅色...
希望 test item, count, last record time欄位內的顏色背景保持白底黑字, 這樣怎麼做呢?IF _GUICtrlListView_GetItemText($hWndListView,$iItem,$iSubItem)="A29" AND $iSubItem=2 Then
$iColor = 0x00FF00
$iColorBk = 0xFFFFFF
Else
$iColor = 0x00FF00
$iColorBk = 0xFFCCFF
DllStructSetData($tCustDraw, "clrText", $iColor)
DllStructSetData($tCustDraw, "clrTextBk", $iColorBk)
tubaba
发表于 2016-10-16 11:35:57
回复 28# ipmitool
select
case_GUICtrlListView_GetItemText($hWndListView,$iItem,$iSubItem)="A29" AND $iSubItem=2
$iColor = 0x00FF00
$iColorBk = 0xFFFFFF
case $iSubItem=2
$iColor = 0x00FF00
$iColorBk = 0xFFCCFF
case else
$iColor = 0x00FF00;指定第三種顏色
$iColorBk = 0xDDEEFF
endselect
DllStructSetData($tCustDraw, "clrText", $iColor)
DllStructSetData($tCustDraw, "clrTextBk", $iColorBk)
Select...Case...EndSelect
如果表达式为 true, 则执行从下一行开始, 直到下一个 Case 或 EndSelect 为止的所有语句.
如果有多个 Case 表达式成立, 则只执行第一个 Case 语句.
ipmitool
发表于 2016-10-16 12:04:14
回复 29# tubaba
太厲害,秒回,成功,謝謝大師