News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

detect a hover with dragged file on a treeview

Started by Shantanu Gadgil, January 07, 2007, 06:48:13 PM

Previous topic - Next topic

Shantanu Gadgil

Hello all,
I have already gone through the following posts:
http://www.masm32.com/board/index.php?topic=4223.0
http://www.masm32.com/board/index.php?topic=3274.0

For now the dragged files are being added under the correct item (by getting a hittest in the WM_DROPFILES), its just that the item under which the dragged files got added is not shown as SELECTED until after I release the mouse.

Is it possible in plain WIN32 (i.e. without COM) to understand the item over which the mouse is hovering when I have dragged files from Explorer onto the treeview?

This so that while I am hovering over the treeview, I can understand _exactly_ which item onto which to drop the files. (kinda like Windows Explorer itself)

Any help would be appreciated,
Regards,
Shantanu
To ret is human, to jmp divine!

Darrel

From my reading you need to respond to the WM_MOUSEMOVE message using TreeView_HitTest and TreeView_SelectDropTarget API's.

HTH,

Darrel

Shantanu Gadgil

Hi Darrel,
The treeview is subclassed and it never gets a WM_MOUSEMOVE when I have dragged files from Explorer onto it.

(Just to be sure what I am doing...)
Selecting some files in Windows Explorer
Dragging them over this treeview in my program (The treeview already has some items in it)
While I am "hovering" over the entire treeview, the subclassed procedure never receives a WM_MOUSEMOVE  :( (I guess that would be because the mouse-leftbutton-down has been captured by Windows Explorer.

As I said before, the user is able to add the items correctly (ie. under the correct item), but he is not able to understand on which item is he exactly dropping the files (He just has to rely on the fact that he has placed the mouse correctly)

(I will post a project with stripped down code later today)

Regards,
Shantanu
To ret is human, to jmp divine!

Darrel


Shantanu Gadgil

A mousehook !?!?!  :dazzled:  :eek :dazzled:

Would that really be necessary??? I am sure there would be a simpler method; using the standard notification messages etc.

Anyway, I will still post the code of what I have done so far...  :bg

Shantanu
To ret is human, to jmp divine!

akane

Mouse hook is not so bad, it can be used commonly with any GUI application to center messagebox to its owner...
Second way: you must use COM and implement IDropTarget class, then call RegisterDragDrop with treeview handle to be always notified while drag-drop operation.
So you will be able to change the cursor, highlight the hot treeview item and so on.

Shantanu Gadgil

Sorry for the delay...will post the code soon. Kinda busy now!  :bg :(

Regards,
Shantanu
To ret is human, to jmp divine!

Shantanu Gadgil

OK...finally got some time to put together the problem description code...

*** Please note, this code is extremely hacky so please don't judge me by it!!!  :P :bdg :bdg

When the program starts, it will add a root item in the treeview and setfocus to the tree, thereby SELECTING that root item. (cheap hack ???)
Now drag some files from Windows Explorer and drop onto the treeview. Let go of the mouse somewhere away form the ROOT item (i.e. don't hover over the root item while your are letting go of the mouse left button)
Files will get added to the ROOT item as it was the SELECTED item in the treeview. (So far so good)
Now drag some more files onto this treeview and move mouse over the already added items (don't let go of mouse left button yet).
Here still the ROOT item is selected.
Now drop them over some child item of the ROOT.
They will get added to the item over which the mouse was when you let go off the mouse left-button, but the user never understand this until after.

The original question was, that while all this (hovering over child item with mouse left button still down) is going on, is there a way to set the item over which we are right now to SELECTED, so that we can indicate to the user where exactly in the tree these items are going to go.

akane, thanks for the "mousehook" info. Just posting this code as said before.

Regards,
Shantanu


[attachment deleted by admin]
To ret is human, to jmp divine!

sinsi

Looks like COM is it (IDropTarget::DragOver gives you mouse coordinates).
Light travels faster than sound, that's why some people seem bright until you hear them.

Darrel

Here's an example using the IDropTarget interface.

Regards,

Darrel

[attachment deleted by admin]

akane

Sorry Shantanu, the "mousehook" was a mistake, it was WH_CBT, but the messagebox can be centered too inside WM_ACTIVATE.