本帖最后由 xyhqqaa 于 2021-1-8 13:51 编辑
因为是链接到mysql,所以这边提供数据估计也作用不大,主要问题是事件模式的写法,小弟也是参考其他大佬的例子学习的,最近学习虚拟列表,想提高下速度。但是无奈一直卡了好几天不求甚解。事情模式俺也是一知半解,特来请教懂的大佬。
写法一,可以链接到mysql获取到数据,参考源自https://www.autoitx.com/forum.ph ... 9%C4%E2%C1%D0%B1%ED
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $tNMTOOLBAR = DllStructCreate($tagNMTOOLBAR, $ilParam)
Local $hWndFrom = HWnd(DllStructGetData($tNMTOOLBAR, "hWndFrom"))
Local $iItem = DllStructGetData($tNMTOOLBAR, "iItem")
Local $iIDFrom = DllStructGetData($tNMTOOLBAR, "IDFrom")
Local $iCode = DllStructGetData($tNMTOOLBAR, "Code")
Switch $iIDFrom
Case $hListView
Switch $iCode
Case $LVN_GETDISPINFOA, $LVN_GETDISPINFOW ;$LVN_GETDISPINFOA = -150, $LVN_GETDISPINFOW = -177
If IsArray($aData) Then
$tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam)
$iItem = DllStructGetData($tInfo, "Item")
$iSubItem = DllStructGetData($tInfo, "SubItem")
If $iSubItem = 0 Then DllStructSetData($tInfo, "Image", 0)
DllStructSetData($tText, "Text", $aData[$iItem][$iSubItem]);
DllStructSetData($tInfo, "Text", DllStructGetPtr($tText));
EndIf
EndSwitch
EndSwitch
EndFunc ;==>WM_NOTIFY
写法二,无法获取数据。该写法源自某大佬的作品,但是不清楚,两者是因为啥区别造成的。
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $tNMTOOLBAR = DllStructCreate($tagNMTOOLBAR, $ilParam)
Local $hWndFrom = HWnd(DllStructGetData($tNMTOOLBAR, "hWndFrom"))
Local $iItem = DllStructGetData($tNMTOOLBAR, "iItem")
Local $iIDFrom = DllStructGetData($tNMTOOLBAR, "IDFrom")
Local $iCode = DllStructGetData($tNMTOOLBAR, "Code")
Switch $hWnd
Case $hListView
tool_ipmanagerEvent_NOTIFY($hWnd, $iIDFrom, $iCode, $ilParam)
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func tool_ipmanagerEvent_NOTIFY($hWnd, $iControl, $iMsg, $ilParam)
Local $Indexlistview = _GUICtrlListView_GetSelectedIndices($hListView)
Local $listruninfo = _GUICtrlListView_GetItemText($hListView, Number($Indexlistview), 0)
Local $hWndListView1 = GUICtrlGetHandle($hListView)
Switch $iControl
Case $hListView ;listview
Switch $iMsg
Case $LVN_GETDISPINFOA, $LVN_GETDISPINFOW ;请求显示数据
If IsArray($array) Then
Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam)
Local $iItem = DllStructGetData($tInfo, "Item")
Local $iSubItem = DllStructGetData($tInfo, "SubItem")
If $iSubItem = 0 Then DllStructSetData($tInfo, "Image", 0)
DllStructSetData($tText, "Text", $array[$iItem][$iSubItem])
DllStructSetData($tInfo, "Text", DllStructGetPtr($tText))
EndIf
EndSwitch
EndSwitch
EndFunc ;==>tool_ipmanagerEvent_NOTIFY
|