Hi bhbcsdn:
API函数的参数确实是个头痛的问题,我记得有本书叫API大全之类的,不过很贵哦。
还有个软件我想推荐给你,是APIGuide,你可用这个连接下载http://www.vbgood.com/iprogram/down/apiguide.zip
该软件为每一个API函数都写了一个或多个例子。
这样:
添加一个List1和一个Command1到Form1上,添加以下代码。运行后按Command1按钮看看是不是你想要的效果:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_VSCROLL = &H115
Private Sub Command1_Click()
Call ItemToTop(List1.hwnd, 30)
End Sub
Private Sub Form_Load()
Dim i As Long
For i = 1 To 100
List1.AddItem "List Item Of Line:" & i
Next i
End Sub
Private Sub ItemToTop(ByVal hwnd As Long, ByVal LineNum As Long)
'本子程序使LineNum行滚到第一行
Dim i As Long
SendMessage hwnd, WM_VSCROLL, 6, 0 '复原
For i = 1 To LineNum - 1
SendMessage hwnd, WM_VSCROLL, 1, 0 '下滚一行
Next i
End Sub
this code can display the 30th item in listview,but not at the top!
If u want it at the top in listview, u must count your listview can display
how many items. Example:
If your listview can display 15 items, u should use this code
listview1.listitem(45).EnsureVisible