Handling related mouse events for the same control

J

John Dann

This question has arisen from an earlier thread but is really a
separate issue:

I have a VB.Net listbox control on a form. I want to be able to do 2
things with items displayed within the one listbox.

1. Reorder items using drag and drop with the mouse.

2. Delete items eg by double-clicking or some other mouse-related
action.

I can get each of these two processes working separately by handling
the MouseDown (as a signal to initiate the drag process) and
DoubleCLick events respectively, but not both together. I'm guessing
that the MouseDown event is fired whenever the mouse is clicked on the
listbox and Windows has no way of distinguishing MouseDown from eg the
start of a doubleclick. With the MouseDown event handled I can no
longer even select items on the listbox.

Anyone agree/disagree with this guess and able to suggest a workaround
please? I suppose also that this complication has maybe arisen because
of wanting to perform multiple mouse actions on the same control -
Drop/Drag often relates to moving data to a different control when the
same issue doesn't necessarily arise. Or am I missing some obvious
solution?

Thanks
JGD
 
G

Guest

I have no direct experience with this issue, but I have two thoughts.

1. Read about the listbox's SetStyle method. The related styles are
StandardClick, StandardDoubleClick, and UserMouse. I doubt if this will help
- it sounds like you are fixed by not knowing whether a Down indicates drag
or an imminent double click. Maybe you could peek the message queue to see
if a double click is present? Sounds ugly to me.

2. My instinct on this problem is to use left for drag and right for a
contextmenu that contains delete and any other operations you might need.
Alternatively, you could use left down for drag and Ctrl+left down for
delete. Upon reading these two sentences, I guess my instinct is to lose the
double click.
 
C

Cor Ligthert

John,

I don't know what you are doing. I think that it is for your problem not
important.


However a normal way to handle this kind of things is setting a switch in
the mousedown event on on. By instance swMouseDown = true and set that to
false in the mouseup event again.

Than you know the status of the mouse.

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top