Treeview SendMessage

Ad1
07-11-2001, 05:13 AM
I am using the following code to enable users to stretch the right hand side of a treeview, the stretching part is working fine but the problem is that the treeview's width property is not updating so that when you try to stretch it again you have to place the mouse over the area where the original right edge was.
I have used the same code with a listbox which worked fine but it seems to be something to do with it being a treeview.
Is there any way I can get it to update its width property

Any help would be greatly appreciated
<pre>Private Declare Function ReleaseCapture Lib "user32" () As Long
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
Const WM_NCLBUTTONDOWN = &HA1
Const HTRIGHT = 11

Private Sub TreeView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)

Dim nParam As Long

If (x > TreeView1.Width - 200 And x < TreeView1.Width) Then
nParam = HTRIGHT
End If
If nParam Then
Call ReleaseCapture
Call SendMessage(TreeView1.hwnd, WM_NCLBUTTONDOWN, nParam, 0)
End If

End Sub

Private Sub TreeView1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)

Dim NewPointer As MousePointerConstants

If (x > TreeView1.Width - 200 And x < TreeView1.Width) Then
NewPointer = vbSizeWE
Else
NewPointer = vbDefault
End If

If NewPointer <> TreeView1.MousePointer Then
TreeView1.MousePointer = NewPointer
End If

End Sub</pre>

vapkse
07-16-2001, 07:24 AM
Hello

Update the width of the treeview in TreeView1_MouseDown

Dim tRc As RECT
Call GetWindowRect(TreeView1.hWnd, tRc)
TreeView1.Width = (tRc.Right - tRc.Left) * Screen.TwipsPerPixelX

Ad1
07-16-2001, 07:49 AM
Thanks vapkse, it works lovely, I'd almost given up on that one

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum