回复 16# chzj589
更貼近我想要的效果的是 這個 你單點看看
我想把顯示 跟 存放資料分開
顯示歸顯示 實際資料歸實際資料
只是我希望是INPUT 控件 不是 LISTVIEW
#PRE_UseX64=n
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
;#include <WinAPITheme.au3>
#include <GuiListView.au3>
#include <WinAPISys.au3>
#include <WinAPI.au3>
#include <GuiEdit.au3>
#include <array.au3>
#include <Misc.au3>
Global $B_DESCENDING[3]
Global $hActLst
Global $bCtrlDown = False
Global $hEdit, $Item = -1, $SubItem = 0
Global $hEnter, $aAccelKeys[1][2] = [["{ENTER}", $hEnter]]
$iSelItem=-1
Local $hUser32 = DllOpen("user32.dll")
Local $ichked = 0
Local $tText = DllStructCreate("wchar Text[256]")
Local $GUI, $hImage
Local $iITEM_COUNT = 1000, $aShowdata[$iITEM_COUNT][4], $aShowdata2[$iITEM_COUNT][4], $aShowdata3[$iITEM_COUNT][4]
Local $sSomeString = ""
Local $hGUI, $hListView, $hListView2, $hListView3
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
$hGUI = GUICreate("ListView[" & UBound($aShowdata) & "]", 600, 605)
$hListView2 = GUICtrlCreateListView("$hListView2| | ", 300, 2, 295, 296, BitOR($LVS_REPORT, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_OWNERDATA), $LVS_EX_GRIDLINES + $LVS_EX_FULLROWSELECT + $LVS_EX_CHECKBOXES+ $LVS_EX_DOUBLEBUFFER);+ $LVS_EX_DOUBLEBUFFER
;~ _WinAPI_SetWindowTheme(GUICtrlGetHandle($hListView), "Explorer");
GUICtrlSendMsg($hListView2, $LVM_SETCOLUMNWIDTH, 0, 110)
GUICtrlSendMsg($hListView2, $LVM_SETCOLUMNWIDTH, 1, 80)
GUICtrlSendMsg($hListView2, $LVM_SETCOLUMNWIDTH, 2, 80)
GUICtrlSendMsg($hListView2, $LVM_SETITEMCOUNT, $iITEM_COUNT, 0);
$hImage = _GUIImageList_Create()
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
_GUICtrlListView_SetImageList($hListView, $hImage, 1);
_GUICtrlListView_SetImageList($hListView2, $hImage, 1);
GUISetState()
For $i = 0 To $iITEM_COUNT - 1
If $i = 18 Then
GUICtrlSendMsg($hListView, $LVM_REDRAWITEMS, 0, $i)
GUICtrlSendMsg($hListView2, $LVM_REDRAWITEMS, 0, $i)
GUICtrlSendMsg($hListView3, $LVM_REDRAWITEMS, 0, $i)
EndIf
$aShowdata2[$i][0] = "100"
$aShowdata2[$i][1] = "1000"
$aShowdata2[$i][2] = "1000000"
$aShowdata2[$i][3] = 4096;
Next
While 1
$bCtrlDown = _IsPressed("11", $hUser32);
Switch GUIGetMsg()
Case -3
ExitLoop
EndSwitch
WEnd
GUIDelete()
DllClose($hUser32)
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 $iIDFrom
Case $hListView2
Switch $iCode
;Case -150, -177 ;$LVN_GETDISPINFOA = -150, $LVN_GETDISPINFOW = -177
Case -177 ; $LVN_GETDISPINFOW = -177
_LVN_GETDISPINFO($iIDFrom, $ilParam, $aShowdata2)
Case $LVN_COLUMNCLICK ;
Case $NM_CLICK;按一下
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$iIndex = DllStructGetData($tInfo, "Index")
$x = DllStructGetData($tInfo, "X")
ConsoleWrite("原始資料為:"&$aShowdata2[$iIndex][0]&" "&$aShowdata2[$iIndex][1]&" "&$aShowdata2[$iIndex][2]&@CRLF)
Case $LVN_BEGINSCROLL ;
Case $NM_DBLCLK ;
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
Func _LVN_GETDISPINFO($hlst, $ilParam, ByRef $aDataArray)
If Not IsArray($aDataArray) Then Return
$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)
If (BitAND(_GUICtrlListView_GetExtendedListViewStyle($hlst), $LVS_EX_CHECKBOXES) = $LVS_EX_CHECKBOXES) Then
DllStructSetData($tInfo, "Mask", BitOR($LVIF_STATE, DllStructGetData($tInfo, "Mask")))
DllStructSetData($tInfo, "StateMask", $LVIS_STATEIMAGEMASK)
DllStructSetData($tInfo, "State", $aDataArray[$iIndex][3])
EndIf
DllStructSetData($tText, "Text", StringRegExpReplace($aDataArray[$iIndex][$iSub], "(?<=(?<!\.)\d)(?=(?:\d{3})+(?:\D|\Z))", ",") )
DllStructSetData($tInfo, "Text", DllStructGetPtr($tText))
DllStructSetData($tInfo, "TextMax", StringLen($aDataArray[$iIndex][$iSub]))
EndFunc
|