Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Two forms with one click 2

Status
Not open for further replies.

krinid

Programmer
Jun 10, 2003
356
CA
Got these two forms which I bring up one at a time. The forms have a single listbox where the users picks an item, which I catch in listbox_Click, then unload the first form and bring up the second form with the next question.

Problem:
When the first form closes and the second form comes up, the mouse button is still clicked and causes the listbox_Click event on the second form to fire. It happens so fast the user may not even notice a form popped up, that they 'clicked' an option and the form unloaded.

Any good ideas to get around this?

Currently, I've done away with _Click and am using _DblClick and it's working fine, but I'd like to use _Click if I can get around this issue. I considered moving the locations of the forms as well so they don't overlap, but of course the best option is to have them come up in the center of the screen (like all other pop-up windows).
 
Gerry,
Interesting, that's useful to know! But are you sure about the order? I don't understand how MouseUp could fire before Click.

In this case, the user presses and holds the mouse button down - ie: hasn't released the mouse (and therefore MouseUp can't fire). But Click has fired, and then afterwards the user releases the button, allowing MouseUp to fire.
 
Well, that seems to be what is happening. However, Help states the events in that order. Hmmmm. I have been playing.

I made a form with a listbox and a label beside it. I made the listbox_click, and the listbox_mousedown and up events write to the label caption - just writing the event name. The write accumulates, it does not clear the caption. I made the label area large enough to mess around with.

When you click an item, and hold the mouse, the MouseDown writes to the label, the listbox click writes to the label. If you continue to hold down, and move the mouse to a new item, the listbox_click fires everytime you move the mouse. Even though you are NOT clicking. It keeps firing until you stop. A counter confirmed that these are independent firings. In my mind solidifying that the click event is not the way to go. I had 15 fires of the click event as I moved the mouse between four items....trying to decide. This seems bad to me, or at least inefficient.

Releasing the mouse fires the Up event, writing to the label. Releasing and clicking the SAME item again, fires Down and Up, but does not fire Listbox_Click - even though you have released and clicked it again.

So, hmmm, clicking and holding can fire MANY Click events - even though only one click is actually made; while clicking many times on the same item only fires one click (which makes sense I guess, even though you are clicking, and the MouseUp and Down events fire).

However, despite what Help states, I have not be able to get a MouseUp to fire before the Click. I think you are correct.

Gerry
 
Gerry,
Excellent tests! That answers the residual questions I had. (Btw, I take it your cat has gray fur?) MouseUp is the way to go! A star for your help.

DarkMain,
Now I see what you were getting at - cheers and a star!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top