Windows标准控件TreeView的滚动条消息问题?

jackjack 2001-10-29 09:09:58
如何接管TreeView自带滚动条的所有消息?请列出具体消息常数?我在用SendMessage发送WM_VSCROLL消息时,参数只能用1才可以,这是什么原因呢?
...全文
136 点赞 收藏 10
写回复
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
playyuer 2001-10-30
参阅:
!!!!!!一筹莫展!!!!!!:关于Listview和Treeview的Drag问题
http://www.csdn.net/expert/topic/330/330389.shtm

实现
1.从 Listview 拖拽 Item 加到 Treeview 的 Node
2.添加 Treeview 节点时,越界可"自动滚动"!!!!!
3.编辑节点的 Text
回复
playyuer 2001-10-30
Option Explicit
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 Const WM_HSCROLL = &H114
Private Sub Command1_Click()
'SendMessage TreeView1.hwnd, WM_VSCROLL, 0, vbNull '上
'SendMessage TreeView1.hwnd, WM_VSCROLL, 1, vbNull '下
'SendMessage TreeView1.hwnd, WM_HSCROLL, 0, vbNull '左
SendMessage TreeView1.hwnd, WM_HSCROLL, 1, vbNull '右
End Sub
Private Sub Form_Load()
Dim i As Integer
TreeView1.Style = tvwTreelinesPlusMinusPictureText
For i = 1 To 50
TreeView1.Nodes.Add , , GetNextKey, "Node " & i
Next i
TreeView1.HideSelection = False
TreeView1.LabelEdit = tvwManual
End Sub
Private Function GetNextKey() As String
Dim sNewKey As String
Dim iHold As Integer
Dim i As Integer
On Error GoTo myerr
iHold = Val(TreeView1.Nodes(1).Key)
For i = 1 To TreeView1.Nodes.Count
If Val(TreeView1.Nodes(i).Key) > iHold Then
iHold = Val(TreeView1.Nodes(i).Key)
End If
Next
iHold = iHold + 1
sNewKey = VBA.CStr(iHold) & "_"
GetNextKey = sNewKey
Exit Function
myerr:
GetNextKey = "1_"
End Function
回复
jackjack 2001-10-30
我去VC论坛问好啦?
回复
jackjack 2001-10-30
To Playyuer:
又给了一次分还是没有显示?帮忙看一下我的问题吧!
回复
jackjack 2001-10-30
奇怪明明给了15分怎么会没有呢?
回复
jackjack 2001-10-30
To Playyuer:
其实我查过Treeview的窗口句柄,看来确实没有办法去掉它?用循环我也知道
"当然用1也是还是可以的)",先给15分吧!
还有一个具体的问题:
用一个滚动条控件如VScrollBar控件,如何让Treeview在变化时,也让该控件变化?
即可以互相传递消息?以达到和其自带滚动条一样目的。
回复
playyuer 2001-10-30
1.循环 Sendmessage 实现滚动多行(参见 ScrollTreeView 过程):
Option Explicit
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 Const WM_HSCROLL = &H114
Public Enum MyScrollDirection
sdDown = 0
sdRight = 1
sdUp = 2
sdLeft = 3
End Enum
Public Sub ScrollTreeView(TreeViewX As MSComctlLib.TreeView, Optional DirectionX As MyScrollDirection, Optional Steps As Integer = 1)
Dim i As Long
For i = 0 To Steps - 1
SendMessage TreeViewX.hwnd, VBA.IIf(DirectionX = sdDown Or DirectionX = sdUp, WM_VSCROLL, WM_HSCROLL), VBA.IIf(DirectionX = sdUp Or DirectionX = sdLeft, 0, 1), vbNull
Next i
End Sub
Private Sub Command1_Click()
ScrollTreeView TreeView1, sdRight, 10 '滚动的多点儿
End Sub
Private Sub Form_Load()
Dim i As Integer
TreeView1.Style = tvwTreelinesPlusMinusPictureText
For i = 1 To 50
TreeView1.Nodes.Add , , GetNextKey, "Node " & i
Next i
TreeView1.HideSelection = False
TreeView1.LabelEdit = tvwManual
End Sub
Private Function GetNextKey() As String
Dim sNewKey As String
Dim iHold As Integer
Dim i As Integer
On Error GoTo myerr
iHold = Val(TreeView1.Nodes(1).Key)
For i = 1 To TreeView1.Nodes.Count
If Val(TreeView1.Nodes(i).Key) > iHold Then
iHold = Val(TreeView1.Nodes(i).Key)
End If
Next
iHold = iHold + 1
sNewKey = VBA.CStr(iHold) & "_"
GetNextKey = sNewKey
Exit Function
myerr:
GetNextKey = "1_"
End Function


2.???? Why???
3.别累了
回复
jackjack 2001-10-30
To playyuer:
1、有没有一个消息可以让Treeview滚动多行?(这还是原来的问题,最好能够这样当然用1也是还是可以的)
3、Treeview的自带的滚动条有没有办法去掉?
2、Treeview的行高是固定的吗?Treeview在做展开、收缩时,其自带滚动条是变化的如何能够得到它的准确的滚动量呢?
回复
jackjack 2001-10-29
赶快啊!
回复
jackjack 2001-10-29
真的没有人会吗?
回复
发动态
发帖子
控件
创建于2007-09-28

1422

社区成员

VB 控件
申请成为版主
社区公告
暂无公告