kk_lee69
发表于 2018-4-13 20:26:38
回复 29# 298311657
恩 我在研究你的範例感謝
分頁的方法 我覺得比較適合沒有 INT 型態 當主鍵的 資料庫
kk_lee69
发表于 2018-4-13 20:27:24
回复 30# yhxhappy
我研究一下你的分頁方式 !!
感謝嚕^^
kk_lee69
发表于 2018-4-16 00:38:19
回复 32# kk_lee69
測試
chzj589
发表于 2018-4-16 16:33:11
回复 33# kk_lee69
这种效果可以吗?
kk_lee69
发表于 2018-4-16 16:44:24
回复 35# chzj589
可以 這也是分業的做法吧
可以看看你怎麼寫的嗎?? 分頁的部分 跟 顯示
chzj589
发表于 2018-4-16 19:22:40
回复 36# kk_lee69
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <SQLite.au3>
#include <GuiComboBox.au3>
Global Const $tagNMLVCACHEHINT = $tagNMHDR & ";int iFrom;int iTo"
Global $hLV, $idLV
Example()
Func Example()
_SQLite_Startup()
; Check databases
Local $iRows1 = CheckDB("Test1.db")
Local $iRows2 = CheckDB("Test2.db")
Local $iRows3 = CheckDB("Test3.db")
Local $iRows
; Create GUI
$hGUI = GUICreate("Virtual ListViews", 850, 450)
; Create Tab
Local $idTab = GUICtrlCreateTab(10, 10, 850 - 20, 400 - 20)
GUICtrlCreateTabItem("Test1.db: " & Format($iRows1) & " rows")
GUICtrlCreateTabItem("Test2.db: " & Format($iRows2) & " rows")
GUICtrlCreateTabItem("Test3.db: " & Format($iRows3) & " rows")
$EButtona1 = GUICtrlCreateLabel("▲", 850 - 40, 450 - 55, 25, 25)
GUICtrlSetColor(-1, 0x00007F);0x010101);
GUICtrlSetFont(-1, 12, 600, 0, 'Arial')
GUICtrlSetBkColor(-1, -2)
GUICtrlSetCursor(-1, 0)
GUICtrlSetState($EButtona1, $GUI_DISABLE)
$EButtona2 = GUICtrlCreateLabel("▼", 850 - 40, 450 - 30, 25, 25)
GUICtrlSetColor(-1, 0x00007F);0x010101);
GUICtrlSetFont(-1, 12, 600, 0, 'Arial')
GUICtrlSetBkColor(-1, -2)
GUICtrlSetCursor(-1, 0)
$Combo = GUICtrlCreateCombo("", 850 - 295, 450 - 48, 125, 22, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL))
_GUICtrlComboBox_SetDroppedWidth($Combo, 160)
GUICtrlSetFont(-1, 10, 600)
GUICtrlSetColor(-1, 0x0000FF);0xFF000F7F);0xfbfcfd);
GUICtrlSetCursor(-1, 0)
$iRows = $iRows3
Local $Rabaa = $iRows
GUICtrlSendMsg($idLV, $LVM_SETITEMCOUNT, $Rabaa, 0)
If $iRows Then _SQLite_Open("Test3.db")
$RSa = $iRows / 100
$Combodata = ''
For $i = 1 To $RSa;.pagecount
$Combodata &= '第' & $i & '页|'
Next
GUICtrlSetData($Combo, "")
GUICtrlSetData($Combo, $Combodata, '第1页')
GUICtrlCreateTabItem("")
; Create ListView
Local $idLV = GUICtrlCreateListView("", 20, 40, 850 - 40, 400 - 60, $LVS_OWNERDATA, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT))
$hLV = GUICtrlGetHandle($idLV) ; Virtual listview Reduces flicker
For $i = 0 To 9
_GUICtrlListView_AddColumn($hLV, "Col" & $i, 75)
Next
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState(@SW_SHOW)
; Data for first tab
$iRows = $iRows1
If $iRows Then _SQLite_Open("Test1.db")
GUICtrlSendMsg($idLV, $LVM_SETITEMCOUNT, $iRows, 0)
While 1
Switch GUIGetMsg()
Case $idTab
If $iRows Then _SQLite_Close(-1)
Switch GUICtrlRead($idTab)
Case 0
$iRows = $iRows1
GUICtrlSendMsg($idLV, $LVM_SETITEMCOUNT, $iRows, 0)
If $iRows Then _SQLite_Open("Test1.db")
Case 1
$iRows = $iRows2
Local $Rabaa = $iRows
GUICtrlSendMsg($idLV, $LVM_SETITEMCOUNT, $Rabaa, 0)
If $iRows Then _SQLite_Open("Test2.db")
$RSa = $iRows / 100
;$DeLabel = GUICtrlCreateLabel('1', 850 - 145, 450 - 45, 28, 17, 0x0002)
;GUICtrlCreateLabel('/' & $RSa, 850 - 115, 450 - 45, 30, 17)
Case 2
$iRows = $iRows3
Local $Rabaa = $iRows
GUICtrlSendMsg($idLV, $LVM_SETITEMCOUNT, $Rabaa, 0)
If $iRows Then _SQLite_Open("Test3.db")
$RSa = $iRows / 100
$DeLabel = GUICtrlCreateLabel('1', 850 - 145, 450 - 45, 28, 17, 0x0002)
GUICtrlCreateLabel('/' & $RSa, 850 - 115, 450 - 45, 30, 17)
EndSwitch
GUICtrlSendMsg($idLV, $LVM_SETITEMCOUNT, $iRows, 0)
Case $GUI_EVENT_CLOSE
ExitLoop
Case $EButtona1
$iRows = $iRows3
Local $Da1 = GUICtrlRead($DeLabel) ;* 100 + 10
Local $Da2 = 1
If $Da1 <= $Da2 Then
MsgBox(0, "1", "己到最前页.", 1)
GUICtrlSetState($EButtona1, $GUI_DISABLE)
GUICtrlSetState($EButtona2, $GUI_ENABLE)
Else
GUICtrlSendMsg($idLV, $LVM_SETITEMCOUNT, 0, 0)
Local $Rab = 10 ;
Local $Rab1 = 10
Local $Raba
Local $tota1 = 1
For $i = 0 To $Rab1
$Raba -= $Rab
;$tota1 = $Raba / 110
Next
$tota1 = $Da1 - 1
GUICtrlSetData($DeLabel, $tota1)
GUICtrlSendMsg($idLV, $LVM_SETITEMCOUNT, $Raba, 0)
If $iRows Then _SQLite_Open("Test3.db")
GUICtrlSetData($Combo, '第' & $tota1 & '页')
Local $iX = _GUICtrlListView_GetItemCount($hLV) - 1
_GUICtrlListView_EnsureVisible($hLV, $iX)
_GUICtrlListView_EndUpdate($hLV)
EndIf
Case $EButtona2
$iRows = $iRows3
GUICtrlSetState($EButtona1, $GUI_ENABLE)
Local $Da1 = GUICtrlRead($DeLabel) ;* $D1 + 10
Local $D1 = $Da1*100
;GUICtrlSetData($DeLabel, "")
If $iRows <= $D1 Then
MsgBox(0, "h", "己到最后页.", 1)
GUICtrlSetState($EButtona2, $GUI_DISABLE)
Else
GUICtrlSendMsg($idLV, $LVM_SETITEMCOUNT, 0, 0)
Local $Rab = 10 ;AND $Ra*30
Local $Rab1 = 10
Local $Raba
Local $total = 1 ;总和
For $i = 1 To $Rab1
$Raba += $Rab1
$total = $Raba / 100;($D1+ 10)
Next
GUICtrlSetData($DeLabel, $total)
GUICtrlSendMsg($idLV, $LVM_SETITEMCOUNT, $Raba, 0)
;If $iRows Then _SQLite_Open("Test1.db")
GUICtrlSetData($Combo, '第' & $total & '页')
Local $iX = _GUICtrlListView_GetItemCount($hLV) - 1
_GUICtrlListView_EnsureVisible($hLV, $iX)
_GUICtrlListView_EndUpdate($hLV)
GUICtrlSetState($EButtona1, $GUI_ENABLE)
EndIf
Case $Combo
GUICtrlSetState($EButtona1, $GUI_ENABLE)
$iRows = $iRows3
Local $Da1 = GUICtrlRead($DeLabel)
If $iRows <= $Da1 Then
MsgBox(0, "h", "己到最后页.", 1)
GUICtrlSetState($EButtona2, $GUI_DISABLE)
Else
;Case $Combo ;下拉选择页次
Local $varxe = StringRegExpReplace(GUICtrlRead($Combo), '[^\d]', '')
$Raba = $varxe * 100
;MsgBox(64, "提示", '打开 第 ' & $varxe & ' 页', 1)
GUICtrlSendMsg($idLV, $LVM_SETITEMCOUNT, $Raba, 0)
;If $iRows Then _SQLite_Open("Test1.db")
GUICtrlSetData($DeLabel, $varxe)
Local $iX = _GUICtrlListView_GetItemCount($hLV) - 1
_GUICtrlListView_EnsureVisible($hLV, $iX)
_GUICtrlListView_EndUpdate($hLV)
EndIf
EndSwitch
WEnd
If $iRows Then _SQLite_Close(-1)
_SQLite_Shutdown()
GUIDelete()
EndFunc ;==>Example
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $ilParam)
Local Static $tText = DllStructCreate("wchar")
Local Static $pText = DllStructGetPtr($tText)
Local Static $aResult, $iRows, $iFrom
Local $tNMHDR, $hWndFrom, $iCode, $idLV, $hWndListView1
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hLV
Switch $iCode
Case $LVN_GETDISPINFOW
Local $tNMLVDISPINFO = DllStructCreate($tagNMLVDISPINFO, $ilParam)
If BitAND(DllStructGetData($tNMLVDISPINFO, "Mask"), $LVIF_TEXT) Then
Local $iIndex = DllStructGetData($tNMLVDISPINFO, "Item") - $iFrom + 1
If $iIndex > 0 And $iIndex < $iRows + 1 Then
Local $sItem = $aResult[$iIndex]
DllStructSetData($tText, 1, $sItem)
DllStructSetData($tNMLVDISPINFO, "Text", $pText)
DllStructSetData($tNMLVDISPINFO, "TextMax", StringLen($sItem))
EndIf
EndIf
Case $LVN_ODCACHEHINT
Local $tNMLVCACHEHINT = DllStructCreate($tagNMLVCACHEHINT, $ilParam), $iColumns
$iFrom = DllStructGetData($tNMLVCACHEHINT, "iFrom")
Local $sSQL = "SELECT * FROM lvdata WHERE item_id >= " & $iFrom & " AND item_id <= " & DllStructGetData($tNMLVCACHEHINT, "iTo") & ";"
_SQLite_GetTable2d(-1, $sSQL, $aResult, $iRows, $iColumns)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func CheckDB($sDBname)
Local $aRow, $iRows = 0
If FileExists($sDBname) Then
_SQLite_Open($sDBname)
_SQLite_QuerySingleRow(-1, "SELECT max(item_id) FROM lvdata;", $aRow)
_SQLite_Close(-1)
EndIf
If IsArray($aRow) Then _
$iRows = $aRow + 1
Return $iRows
EndFunc ;==>CheckDB
Func Format($iInt)
Return StringRegExpReplace($iInt, "(\A\d{1,3}(?=(\d{3})+\z)|\d{3}(?=\d))", "\1,")
EndFunc ;==>Format