kk_lee69
发表于 2018-5-18 12:34:38
回复 30# qsy666888
可以做到 晚點再跟你說吧外出
xz00311
发表于 2018-5-18 16:48:02
能不能把解决的源码放上来了
chzj589
发表于 2018-5-18 20:55:07
回复chzj589
假如说我需要在首列加入图标,换底色就会把图标丢失
qsy666888 发表于 2018-5-18 10:48 http://www.autoit3.cn/images/common/back.gif
不会啊
qsy666888
发表于 2018-5-18 21:02:01
本帖最后由 qsy666888 于 2018-5-18 21:04 编辑
回复 33# chzj589
我想最终效果24楼图,你这种只能用K大的方法,如果用 GUICtrlSetBkColor(_GUICtrlListView_GetItemParam($ListView1, $a), '0x66CD00')这个的话图标会受到影响
kk_lee69
发表于 2018-5-18 21:30:33
回复 34# qsy666888
怪了~~~ 是你阿上次圖標問題不就是你問的嗎?? 我也給你範例了
你自己都可以做到 前面 沒圖標 後面有阿
http://www.autoit3.cn/thread-56599-3-3.html
qsy666888
发表于 2018-5-18 21:35:53
回复 35# kk_lee69
就是前面有图标,去不掉
kk_lee69
发表于 2018-5-18 21:56:27
回复 36# qsy666888
給前面一個 不存在的圖標 編號 就好
_GUICtrlListView_AddItem($listview, "Zeile 1: Spalte 1",55)
圖標清單 沒有55 就不會出現圖標
kk_lee69
发表于 2018-5-18 22:13:11
回复 36# qsy666888
你現在的 程式範例 提供一下吧我看怎麼幫你改
qsy666888
发表于 2018-5-18 22:35:40
回复 38# kk_lee69
#Include <GuiListView.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
#Include <GuiListView.au3>
#Include <GuiTreeView.au3>
#include <GuiConstantsEx.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
Global $hQuery
_SQLite_Startup ()
$SQLite_Data_Path =@ScriptDir&"\SQLite.db"
$Tablekj = "kaojuan"
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("從資料庫裡獲取姓名示例", 478, 412, 481, 210)
GUISetFont(11, 400, 0, "宋體")
Global $ListView1 = GUICtrlCreateListView("序號|姓名|語文||", 8, 8, 458, 358)
GUICtrlSetBkColor($ListView1,0xC0C0A5)
_GUICtrlListView_SetBkColor($ListView1, $CLR_MONEYGREEN)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES,$LVS_NOSCROLL ))
$hImage = _GUIImageList_Create(20, 20, 5, 3)
KC_lvdraw()
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll",1);50
; _GUIImageList_AddIcon($hImage, @ScriptDir & "\icon\101.ico")
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll",13)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll",24);50
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll",34)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll",44)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll",54)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll",64)
_GUICtrlListView_SetImageList($ListView1, $hImage, 1)
_GUICtrlListView_AddSubItem($ListView1, 0, "", 3, 1)
_GUICtrlListView_AddSubItem($ListView1, 1, "", 3, 2)
_GUICtrlListView_AddSubItem($ListView1, 2, "", 3, 3)
_GUICtrlListView_AddSubItem($ListView1, 3, "", 3, 4)
_GUICtrlListView_AddSubItem($ListView1, 4, "", 3, 5)
_GUICtrlListView_AddSubItem($ListView1, 5, "", 3, 6)
Global $Button1 = GUICtrlCreateButton("查看分數", 293, 376, 75, 25)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
;Case $Button1
; msgbox(0,"70多分者", _get_N(7, 1))
; msgbox(0,"分數個位數是5者", _get_N(5, 0))
EndSwitch
WEnd
Func _get_N($iNum, $iCode = 1)
Local $aRow, $hQuery, $sMsg = ''
Local $sQuery
If $iCode Then
$sQuery = "'" & $iNum & "%'"
Else
$sQuery = "'%" & $iNum & "'"
EndIf
_SQLite_Open ($SQLite_Data_Path)
_SQLite_Query(-1, "SELECT * FROM kaojuan WHERE 分數 LIKE " & $sQuery & ";", $hQuery)
While _SQLite_FetchData($hQuery, $aRow) = $sqlite_ok
$sMsg &= $aRow & @TAB & $aRow & @CRLF
WEnd
Return $sMsg
EndFunc
Func KC_lvdraw()
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1))
Global $Irval, $Aresult, $Irows, $Icolumns,$sQuery,$aRowa,$a = '',$b = '',$c = ''
$Irval = _SQLite_GetTable2d( _SQLite_Open ($SQLite_Data_Path), "select rowid,* from kaojuan;", $Aresult, $Irows, $Icolumns)
;GUICtrlSetColor($ListView1, 0x000000)
_ArrayDelete($aresult, 0)
_GUICtrlListView_AddArray($ListView1, $Aresult)
_SQLite_QueryFinalize($hQuery)
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
;~Local $tBuffer
$hWndListView = $ListView1
If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_CUSTOMDRAW;顏色的處理部份 需搭配上面繪圖的處理
Local $iDrawStage, $iIndex, $iSub,$iColor, $hDC
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
If Not BitAND($iDrawStage, $CDDS_SUBITEM) Then Return $CDRF_DODEFAULT
Local $iIndex = DllStructGetData($tCustDraw, "dwItemSpec")
Local $iSub = DllStructGetData($tCustDraw, "iSubItem")
;$CHKIDSerch=$iIndex
;$VLSIDSerch=_GUICtrlListView_GetSelectedIndices($VListViewSerch,True)
;這一段處理變色 跟判斷
IF _GUICtrlListView_GetItemText($hWndListView,$iIndex,2) <60 Then
DllStructSetData($tCustDraw, "clrText", 0x55FF55)
DllStructSetData($tCustDraw, "clrTextBk", 0x80FFFF)
Else
EndIf
Return $CDRF_NEWFONT
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
kk_lee69
发表于 2018-5-18 22:49:58
回复 39# qsy666888
#Include <GuiListView.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
#Include <GuiListView.au3>
#Include <GuiTreeView.au3>
#include <GuiConstantsEx.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
Global $hQuery
_SQLite_Startup ()
$SQLite_Data_Path =@ScriptDir&"\SQLite.db"
$Tablekj = "kaojuan"
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("從資料庫裡獲取姓名示例", 478, 412, 481, 210)
GUISetFont(11, 400, 0, "宋體")
Global $ListView1 = GUICtrlCreateListView("序號|姓名|語文||", 8, 8, 458, 358)
GUICtrlSetBkColor($ListView1,0xC0C0A5)
_GUICtrlListView_SetBkColor($ListView1, $CLR_MONEYGREEN)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES,$LVS_NOSCROLL ))
$hImage = _GUIImageList_Create(20, 20, 5, 3)
KC_lvdraw()
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll",1);50
; _GUIImageList_AddIcon($hImage, @ScriptDir & "\icon\101.ico")
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll",13)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll",24);50
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll",34)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll",44)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll",54)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll",64)
_GUICtrlListView_SetImageList($ListView1, $hImage, 1)
_GUICtrlListView_AddSubItem($ListView1, 0, "", 3, 1)
_GUICtrlListView_AddSubItem($ListView1, 1, "", 3, 2)
_GUICtrlListView_AddSubItem($ListView1, 2, "", 3, 3)
_GUICtrlListView_AddSubItem($ListView1, 3, "", 3, 4)
_GUICtrlListView_AddSubItem($ListView1, 4, "", 3, 5)
_GUICtrlListView_AddSubItem($ListView1, 5, "", 3, 6)
Global $Button1 = GUICtrlCreateButton("查看分數", 293, 376, 75, 25)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
;Case $Button1
; msgbox(0,"70多分者", _get_N(7, 1))
; msgbox(0,"分數個位數是5者", _get_N(5, 0))
EndSwitch
WEnd
Func _get_N($iNum, $iCode = 1)
Local $aRow, $hQuery, $sMsg = ''
Local $sQuery
If $iCode Then
$sQuery = "'" & $iNum & "%'"
Else
$sQuery = "'%" & $iNum & "'"
EndIf
_SQLite_Open ($SQLite_Data_Path)
_SQLite_Query(-1, "SELECT * FROM kaojuan WHERE 分數 LIKE " & $sQuery & ";", $hQuery)
While _SQLite_FetchData($hQuery, $aRow) = $sqlite_ok
$sMsg &= $aRow & @TAB & $aRow & @CRLF
WEnd
Return $sMsg
EndFunc
Func KC_lvdraw()
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1))
Global $Irval, $Aresult, $Irows, $Icolumns,$sQuery,$aRowa,$a = '',$b = '',$c = ''
$Irval = _SQLite_GetTable2d( _SQLite_Open ($SQLite_Data_Path), "select rowid,* from kaojuan;", $Aresult, $Irows, $Icolumns)
;GUICtrlSetColor($ListView1, 0x000000)
_ArrayDelete($aresult, 0)
_GUICtrlListView_AddArray($ListView1, $Aresult)
_SQLite_QueryFinalize($hQuery)
_GUICtrlListView_SetItemImage($ListView1,0,55)
_GUICtrlListView_SetItemImage($ListView1,1,55)
_GUICtrlListView_SetItemImage($ListView1,2,55)
_GUICtrlListView_SetItemImage($ListView1,3,55)
_GUICtrlListView_SetItemImage($ListView1,4,55)
_GUICtrlListView_SetItemImage($ListView1,5,55)
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
;~Local $tBuffer
$hWndListView = $ListView1
If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_CUSTOMDRAW;顏色的處理部份 需搭配上面繪圖的處理
Local $iDrawStage, $iIndex, $iSub,$iColor, $hDC
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
If Not BitAND($iDrawStage, $CDDS_SUBITEM) Then Return $CDRF_DODEFAULT
Local $iIndex = DllStructGetData($tCustDraw, "dwItemSpec")
Local $iSub = DllStructGetData($tCustDraw, "iSubItem")
;$CHKIDSerch=$iIndex
;$VLSIDSerch=_GUICtrlListView_GetSelectedIndices($VListViewSerch,True)
;這一段處理變色 跟判斷
IF _GUICtrlListView_GetItemText($hWndListView,$iIndex,2) <60 Then
DllStructSetData($tCustDraw, "clrText", 0x55FF55)
DllStructSetData($tCustDraw, "clrTextBk", 0x80FFFF)
Else
EndIf
Return $CDRF_NEWFONT
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
kk_lee69
发表于 2018-5-18 22:56:20
回复 39# qsy666888
另外一個方法 是把 第一列 掉到後面
這樣著色上面應該會比較漂亮
#Include <GuiListView.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
#Include <GuiListView.au3>
#Include <GuiTreeView.au3>
#include <GuiConstantsEx.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
Global $hQuery
_SQLite_Startup ()
$SQLite_Data_Path =@ScriptDir&"\SQLite.db"
$Tablekj = "kaojuan"
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("從資料庫裡獲取姓名示例", 478, 412, 481, 210)
GUISetFont(11, 400, 0, "宋體")
Global $ListView1 = GUICtrlCreateListView(" |序號|姓名|語文", 8, 8, 458, 358)
$hImage = _GUIImageList_Create(20, 20, 5, 3)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll",1);50
; _GUIImageList_AddIcon($hImage, @ScriptDir & "\icon\101.ico")
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll",2)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll",3);50
_GUICtrlListView_SetImageList($ListView1, $hImage, 1)
_GUICtrlListView_SetColumnOrder(GUICtrlGetHandle($ListView1), "1|2|3|0")
KC_lvdraw()
Global $Button1 = GUICtrlCreateButton("查看分數", 293, 376, 75, 25)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
;Case $Button1
; msgbox(0,"70多分者", _get_N(7, 1))
; msgbox(0,"分數個位數是5者", _get_N(5, 0))
EndSwitch
WEnd
Func _get_N($iNum, $iCode = 1)
Local $aRow, $hQuery, $sMsg = ''
Local $sQuery
If $iCode Then
$sQuery = "'" & $iNum & "%'"
Else
$sQuery = "'%" & $iNum & "'"
EndIf
_SQLite_Open ($SQLite_Data_Path)
_SQLite_Query(-1, "SELECT * FROM kaojuan WHERE 分數 LIKE " & $sQuery & ";", $hQuery)
While _SQLite_FetchData($hQuery, $aRow) = $sqlite_ok
$sMsg &= $aRow & @TAB & $aRow & @CRLF
WEnd
Return $sMsg
EndFunc
Func KC_lvdraw()
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1))
Global $Irval, $Aresult, $Irows, $Icolumns,$sQuery,$aRowa,$a = '',$b = '',$c = ''
$Irval = _SQLite_GetTable2d( _SQLite_Open ($SQLite_Data_Path), "select '' as a,rowid,*from kaojuan;", $Aresult, $Irows, $Icolumns)
;GUICtrlSetColor($ListView1, 0x000000)
_ArrayDelete($aresult, 0)
_GUICtrlListView_AddArray($ListView1, $Aresult)
_SQLite_QueryFinalize($hQuery)
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
;~Local $tBuffer
$hWndListView = $ListView1
If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_CUSTOMDRAW;顏色的處理部份 需搭配上面繪圖的處理
Local $iDrawStage, $iIndex, $iSub,$iColor, $hDC
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
If Not BitAND($iDrawStage, $CDDS_SUBITEM) Then Return $CDRF_DODEFAULT
Local $iIndex = DllStructGetData($tCustDraw, "dwItemSpec")
Local $iSub = DllStructGetData($tCustDraw, "iSubItem")
;$CHKIDSerch=$iIndex
;$VLSIDSerch=_GUICtrlListView_GetSelectedIndices($VListViewSerch,True)
;這一段處理變色 跟判斷
IF _GUICtrlListView_GetItemText($hWndListView,$iIndex,3) <60 Then
DllStructSetData($tCustDraw, "clrText", 0x55FF55)
DllStructSetData($tCustDraw, "clrTextBk", 0x80FFFF)
Else
EndIf
Return $CDRF_NEWFONT
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
qsy666888
发表于 2018-5-18 22:56:55
回复 39# qsy666888
还有这两段代码合在一起的话有冲突,一个是鼠标事件注册,一个是颜色修改
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $iCode
Case $NM_CLICK
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$iIndex = DllStructGetData($tInfo, "Index")
$iSub = DllStructGetData($tInfo, "SubItem")
IF$iIndex=0 AND $iSub=3 Then
ConsoleWrite("你點了+"&@CRLF)
MsgBox(0,"","你點了+")
ElseIf $iIndex=0 AND $iSub=4 Then
MsgBox(0,"","你點了搜尋")
ElseIf $iIndex=0 AND $iSub=5 Then
MsgBox(0,"","你點了停止")
EndIf
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
;~Local $tBuffer
$hWndListView = $ListView1
If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_CUSTOMDRAW;顏色的處理部份 需搭配上面繪圖的處理
Local $iDrawStage, $iIndex, $iSub,$iColor, $hDC
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
If Not BitAND($iDrawStage, $CDDS_SUBITEM) Then Return $CDRF_DODEFAULT
Local $iIndex = DllStructGetData($tCustDraw, "dwItemSpec")
Local $iSub = DllStructGetData($tCustDraw, "iSubItem")
;$CHKIDSerch=$iIndex
;$VLSIDSerch=_GUICtrlListView_GetSelectedIndices($VListViewSerch,True)
;這一段處理變色 跟判斷
IF _GUICtrlListView_GetItemText($hWndListView,$iIndex,2) <60 Then
DllStructSetData($tCustDraw, "clrText", 0x55FF55)
DllStructSetData($tCustDraw, "clrTextBk", 0x80FFFF)
Else
EndIf
Return $CDRF_NEWFONT
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
我把两段代码结合在一起,如果注释掉Switch $hWndFrom
Case $hWndListView
Switch $iCode,可以对表格里的条件起反应效果,但对其它控件的颜色有影响,全部变成黑色,如果加上这三句代码,其它正常,对表格里的条件判断失去效应
kk_lee69
发表于 2018-5-18 23:00:28
回复 42# qsy666888
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
;~Local $tBuffer
$hWndListView = $ListView1
If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Case $NM_CLICK
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$iIndex = DllStructGetData($tInfo, "Index")
$iSub = DllStructGetData($tInfo, "SubItem")
IF$iIndex=0 AND $iSub=3 Then
ConsoleWrite("你點了+"&@CRLF)
MsgBox(0,"","你點了+")
ElseIf $iIndex=0 AND $iSub=4 Then
MsgBox(0,"","你點了搜尋")
ElseIf $iIndex=0 AND $iSub=5 Then
MsgBox(0,"","你點了停止")
EndIf
Switch $iCode
Case $NM_CUSTOMDRAW;顏色的處理部份 需搭配上面繪圖的處理
Local $iDrawStage, $iIndex, $iSub,$iColor, $hDC
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
If Not BitAND($iDrawStage, $CDDS_SUBITEM) Then Return $CDRF_DODEFAULT
Local $iIndex = DllStructGetData($tCustDraw, "dwItemSpec")
Local $iSub = DllStructGetData($tCustDraw, "iSubItem")
;$CHKIDSerch=$iIndex
;$VLSIDSerch=_GUICtrlListView_GetSelectedIndices($VListViewSerch,True)
;這一段處理變色 跟判斷
IF _GUICtrlListView_GetItemText($hWndListView,$iIndex,2) <60 Then
DllStructSetData($tCustDraw, "clrText", 0x55FF55)
DllStructSetData($tCustDraw, "clrTextBk", 0x80FFFF)
Else
EndIf
Return $CDRF_NEWFONT
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
qsy666888
发表于 2018-5-18 23:02:21
回复 43# kk_lee69
感谢感谢,我先试试
chzj589
发表于 2018-5-21 19:23:49
回复 43# kk_lee69
图标显示用GUICtrlCreateIcon处理
效果图: