#include <GuiListView.au3>
#include <WindowsConstants.au3>
$var = IniReadSection(@ScriptDir & '\Config.ini', 'Config')
If @error Then Exit MsgBox(48, "出错!", "发生错误,INI文件读取失败!") ;INI文件读取错误将退出
Dim $iChange = 25, $dqyc = 1 ;$iChange 每页显示多少个项目;$dqyc 为当前页次
Dim $zys = Ceiling($var[0][0] / $iChange)
GUICreate("Listview分页显示", 400, 450)
$ListView1 = GUICtrlCreateListView("编号|内容", 5, 5, 390, 380, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT, $LVS_REPORT))
_GUICtrlListView_SetColumnWidth($ListView1, 0, 100)
_GUICtrlListView_SetColumnWidth($ListView1, 1, 280)
$Button1 = GUICtrlCreateButton("<", 110, 400, 30, 22)
$Button2 = GUICtrlCreateButton(">", 190, 400, 30, 22)
$Label = GUICtrlCreateLabel('1', 143, 405, 18, 17, 0x0002)
GUICtrlCreateLabel('/' & $zys, 162, 405, 23, 17)
$Button3 = GUICtrlCreateButton("返回首页", 30, 400, 80, 22)
$Button4 = GUICtrlCreateButton("跳至尾页", 220, 400, 80, 22)
$Combo = GUICtrlCreateCombo('', 305, 402, 60, 22)
$Combodata = ''
For $i = 1 To $zys
$Combodata &= '第' & $i & '页|'
Next
GUICtrlSetData(-1, $Combodata, '第1页')
GUISetState()
Go(1) ;首次读取
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1 ;上一页
Go($dqyc - 1)
Case $Button2 ;下一页
Go($dqyc + 1)
Case $Button3 ;首页
Go(1)
Case $Button4 ;尾页
Go($zys)
Case $Combo ;下拉选择页次
Go(StringRegExpReplace(GUICtrlRead($Combo), '[^\d]', ''))
EndSwitch
WEnd
Func Go($yc)
Local $iNo1 = ($yc - 1) * $iChange + 1
Local $iNo2
If $yc = $zys Then
$iNo2 = $var[0][0]
SetState(64, 128, 64, 128)
ElseIf $yc = 1 Then
$iNo2 = $iNo1 + $iChange - 1
SetState(128, 64, 128, 64)
Else
$iNo2 = $iNo1 + $iChange - 1
SetState(64, 64, 64, 64)
EndIf
Read($iNo1, $iNo2)
GUICtrlSetData($Label, $yc)
GUICtrlSetData($Combo, '第' & $yc & '页')
$dqyc = $yc
EndFunc ;==>Go
Func SetState($1, $2, $3, $4)
GUICtrlSetState($Button1, $1)
GUICtrlSetState($Button2, $2)
GUICtrlSetState($Button3, $3)
GUICtrlSetState($Button4, $4)
EndFunc ;==>SetState
Func Read($iNo1, $iNo2)
_GUICtrlListView_DeleteAllItems($ListView1)
For $i = $iNo1 To $iNo2
GUICtrlCreateListViewItem($var[$i][0] & '|' & $var[$i][1], $ListView1)
Next
EndFunc ;==>Read