有办法在虚拟 LISTVIEW 里面加入$LVS_EX_CHECKBOXES 的风格吗??
以下是虚拟 LISTVIEW+$LVS_EX_CHECKBOXES 后的效果,可以看出$LVS_EX_CHECKBOXES 的位置有出来,但是图案没出来 ,有人可以解决这个问题吗??
;~ 關於虛擬列表的一份說明
;~ http://blog.vckbase.com/iwaswzq/archive/2006/07/07/21113.aspx
#cs ____________________________________
Au3 版本: 3.3.9.0
腳本作者: CrossDoor
電子郵件: 382869232@qq.com
QQ/TM: 382869232
#ce _______________腳本開始_________________
#Region ;**** 參數創建於 ACNWrapper_GUI ****
#PRE_UseX64=n
#EndRegion ;**** 參數創建於 ACNWrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <array.au3>
Global $B_DESCENDING[3] ; 排序用陣列
Local $tText = DllStructCreate("wchar Text[512]");建個結構,用來放listview列資料
Local $GUI, $hImage, $iITEM_COUNT = 10000
Local $sSomeString = ""
Local $aBoy[$iITEM_COUNT][3], $aGirl[$iITEM_COUNT][3]
For $i = 0 To $iITEM_COUNT - 1;初始化陣列
$aBoy[$i][0] = "爺爺" & $i
$aBoy[$i][1] = "爸爸" & $i
$aBoy[$i][2] = "兒子" & $i
$aGirl[$i][0] = "奶奶" & $i
$aGirl[$i][1] = "媽媽" & $i
$aGirl[$i][2] = "女兒" & $i
Next
Local $aShowdata = $aBoy
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
$hGUI = GUICreate("ListView虛擬清單 載入[" & $iITEM_COUNT & "]數據", 500, 350)
;$hListView = GUICtrlCreateListView("Item1|nSubItem1|nSubItem2", 2, 2, 494, 294, $LVS_SHOWSELALWAYS + $LVS_OWNERDATA, $LVS_EX_GRIDLINES + $LVS_EX_FULLROWSELECT + $LVS_EX_DOUBLEBUFFER);不加CHECKBOX
$hListView = GUICtrlCreateListView("Item1|nSubItem1|nSubItem2", 2, 2, 494, 294, $LVS_SHOWSELALWAYS + $LVS_OWNERDATA, $LVS_EX_GRIDLINES + $LVS_EX_FULLROWSELECT + $LVS_EX_DOUBLEBUFFER+$LVS_EX_CHECKBOXES)
;設置列寬
GUICtrlSendMsg($hListView, $LVM_SETCOLUMNWIDTH, 0, 150)
GUICtrlSendMsg($hListView, $LVM_SETCOLUMNWIDTH, 1, 150)
GUICtrlSendMsg($hListView, $LVM_SETCOLUMNWIDTH, 2, 150)
GUICtrlSendMsg($hListView, $LVM_SETITEMCOUNT, $iITEM_COUNT, 0);分配清單記憶體。 為什麼要這樣做?因為虛擬清單必須要知道資料總量
;創建並關聯圖像清單
$hImage = _GUIImageList_Create()
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 115)
_GUICtrlListView_SetImageList($hListView, $hImage, 1)
$Button1 = GUICtrlCreateButton("男", 20, 310, 75, 25)
$Button2 = GUICtrlCreateButton("女", 100, 310, 75, 25)
$Button3 = GUICtrlCreateButton("修改", 180, 310, 75, 25)
$Button4 = GUICtrlCreateButton("清空", 260, 310, 75, 25)
GUISetState()
Local $iCol
While 1
$iMsg = GUIGetMsg()
Switch $iMsg
Case -3
ExitLoop
Case $Button1
$aShowdata = $aBoy
GUICtrlSendMsg($hListView, $LVM_ENSUREVISIBLE, 1, 0)
GUICtrlSendMsg($hListView, $LVM_REDRAWITEMS, 0, 20)
Case $Button2
$aShowdata = $aGirl
GUICtrlSendMsg($hListView, $LVM_ENSUREVISIBLE, 1, 0)
GUICtrlSendMsg($hListView, $LVM_REDRAWITEMS, 0, 20)
Case $Button3
If StringLen($sSomeString) Then
$sSomeString = ""
Else
$sSomeString = Asc(Random(48, 255, 1))
EndIf
GUICtrlSendMsg($hListView, $LVM_ENSUREVISIBLE, 1, 0)
GUICtrlSendMsg($hListView, $LVM_REDRAWITEMS, 0, 20)
Case $Button4
$aShowdata = 0
$iITEM_COUNT = 0
GUICtrlSendMsg($hListView, $LVM_SETITEMCOUNT, $iITEM_COUNT, 0)
GUICtrlSendMsg($hListView, $LVM_ENSUREVISIBLE, 1, 0)
GUICtrlSendMsg($hListView, $LVM_REDRAWITEMS, 0, 20)
EndSwitch
WEnd
GUIDelete()
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo, $s
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Local $iIndex = DllStructGetData($tNMHDR, 'Index')
Switch $iIDFrom
Case $hListView
Switch $iCode
Case $LVN_COLUMNCLICK ; 點擊列頭排序
$tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
$iSub = DllStructGetData($tInfo, "SubItem")
_ArraySort($aShowdata, $B_DESCENDING[$iSub], 0, 0, $iSub)
GUICtrlSendMsg($hListView, $LVM_ENSUREVISIBLE, 1, 0)
GUICtrlSendMsg($hListView, $LVM_REDRAWITEMS, 0, 20)
$B_DESCENDING[$iSub] = Not $B_DESCENDING[$iSub]
Case $NM_DBLCLK ; 按兩下
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$iIndex = DllStructGetData($tInfo, "Index")
$iSub = DllStructGetData($tInfo, "SubItem")
MsgBox(0, $iIndex, $aShowdata[$iIndex][$iSub])
Case - 150, -177 ;$LVN_GETDISPINFOA = -150, $LVN_GETDISPINFOW = -177
If Not IsArray($aShowdata) Then ContinueCase
$tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam)
$iIndex = Int(DllStructGetData($tInfo, "Item"))
$iSub = Int(DllStructGetData($tInfo, "SubItem"))
IF BitAND(DllStructGetData($tInfo, "Mask"), $LVIF_IMAGE) And $iSub = 0 THEN DllStructSetData($tInfo, "Image", 0);設置列圖像
$s = $aShowdata[$iIndex][$iSub] & "-" & $sSomeString
DllStructSetData($tText, "Text", $s);列資料放入$tText結構
DllStructSetData($tInfo, "Text", DllStructGetPtr($tText));用$tText結構的指標來設置列資料
DllStructSetData($tInfo, "TextMax", StringLen($s));設置列數據長度
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
|