|
-
Mar 10th, 2008, 03:16 AM
#1
Thread Starter
PowerPoster
Invalid use of AddressOf operator
Hi Guys,
This is part of my code to create a drag image of the treeview item being dragged:
Code:
Public Sub TreeView_StartDrag( _
ByVal hWndTreeView As Long, _
Optional ByVal x As Long = 20, _
Optional ByVal y As Long = 20)
Dim tPoint As POINTL
Dim hItem As Long
' Get the selected node
hItem = SendMessage(hWndTreeView, TVM_GETNEXTITEM, TVGN_DROPHILITE, ByVal 0&)
' Get a ImageList with the drag image
m_lIL = SendMessage(hWndTreeView, TVM_CREATEDRAGIMAGE, 0, ByVal hItem)
' Start the image dragging
ImageList_BeginDrag m_lIL, 0, x, y
ImageList_DragEnter 0, 0, 0
' Start the timer
m_lTimer = SetTimer(0, 0, 1, AddressOf pvTimerDragMove)
End Sub
Private Sub pvTimerDragMove( _
ByVal hWnd As Long, _
ByVal uMsg As Long, _
ByVal idEvent As Long, _
ByVal dwTime As Long)
Dim tPoint As POINTL
' Get the cursor position
GetCursorPos tPoint
' Move the image to the new cursor position
ImageList_DragMove tPoint.x, tPoint.y
End Sub
I get an invalid use of AddressOf operator on the line I have highlighted in red. Please help
-
Mar 10th, 2008, 03:25 AM
#2
Re: Invalid use of AddressOf operator
You can only use AddressOf to point to something in a .Bas module. pvTimerDragMove must be in a Module as opposed to a Form
-
Mar 10th, 2008, 03:45 AM
#3
Thread Starter
PowerPoster
Re: Invalid use of AddressOf operator
Thanks Doogle,
That fixed the problem.
I am using the code from this site:
http://www.mvps.org/emorcillo/en/cod...ropimage.shtml
but it isn't creating the drag image. could someone please test this code. I would post my project but I have stored procedures for populating my treeview.
-
Mar 10th, 2008, 03:58 AM
#4
Thread Starter
PowerPoster
Re: Invalid use of AddressOf operator
Guys, these to lines always return 0.
Code:
hItem = SendMessage(hWndTreeView, TVM_GETNEXTITEM, TVGN_DROPHILITE, ByVal 0&)
' Get a ImageList with the drag image
m_lIL = SendMessage(hWndTreeView, TVM_CREATEDRAGIMAGE, 0, ByVal hItem)
hitem and m_lIL are always zero
-
Mar 10th, 2008, 04:23 AM
#5
Re: Invalid use of AddressOf operator
Have you looked at Err.LastDllError after the first sendmessage fails. It may give you a hint as to what's wrong.
-
Mar 10th, 2008, 04:28 AM
#6
Thread Starter
PowerPoster
Re: Invalid use of AddressOf operator
Hi Doogle,
It returns 0.
-
Mar 10th, 2008, 04:35 AM
#7
Re: Invalid use of AddressOf operator
So it's not 'failing' in that sense, looking at the documentation for the message (http://msdn2.microsoft.com/en-us/lib...22(VS.85).aspx) the remarks say
This message will return NULL if the item being retrieved is the root node of the tree.
Perhaps that's the problem(?)
-
Mar 10th, 2008, 05:01 AM
#8
Thread Starter
PowerPoster
Re: Invalid use of AddressOf operator
these are the values I assign to those variables:
Code:
Const TVM_CREATEDRAGIMAGE = &H1100& + 18
Const TVM_GETNEXTITEM = &H1100& + 10
Const TVGN_DROPHILITE = &H8
-
Mar 10th, 2008, 05:11 AM
#9
Re: Invalid use of AddressOf operator
Thpse values look ok to me. If they were incorrect I suspect you'd see a non-zero Err.LastDllError. Is the drop target the roor of the treeview?
-
Mar 10th, 2008, 05:35 AM
#10
Thread Starter
PowerPoster
Re: Invalid use of AddressOf operator
No it isn't. Those variables need to take on a value greater than zero once the dragging begins. That doesn't happen. I'm assuming that is why no image gets created.
-
Mar 10th, 2008, 06:34 AM
#11
Thread Starter
PowerPoster
Re: Invalid use of AddressOf operator
Hey Guys, I think I fixed it ,
I added this into my module:
Code:
Private Const TVGN_CARET = 9
and changed this line to the following:
Code:
hitem = SendMessage(hWndTreeView, TVM_GETNEXTITEM, TVGN_CARET, ByVal 0&)
seems right. Can anyone verify that I am right please.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|