By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,965 Members | 2,043 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,965 IT Pros & Developers. It's quick & easy.

Handling related mouse events for the same control

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.
"John Dann" wrote:
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

Nov 21 '05 #2

P: n/a
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
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.