Board index » delphi » Mouse Click Being Processed Twice

Mouse Click Being Processed Twice

I have a problem with a modal dialog I bring up over the main form in
an application. When the OK button is pressed, this dialog is closed,
but then the same mouse click processed by the Ok button is also
processed by another control on the main form, because the position of
the OK button on the dialog happens to be positioned over the other
control when the mouse is clicked and the dialog closes. I wouldn't
think that this should be happening, and it's very annoying. Is there
anything I can do to prevent this 'extra' processing of this mouse
click?
 

Re:Mouse Click Being Processed Twice


Are you showing the modal dialog in an OnExit event?
Quote
"Kevin R." wrote:

> I have a problem with a modal dialog I bring up over the main form in
> an application. When the OK button is pressed, this dialog is closed,
> but then the same mouse click processed by the Ok button is also
> processed by another control on the main form, because the position of
> the OK button on the dialog happens to be positioned over the other
> control when the mouse is clicked and the dialog closes. I wouldn't
> think that this should be happening, and it's very annoying. Is there
> anything I can do to prevent this 'extra' processing of this mouse
> click?

Re:Mouse Click Being Processed Twice


On Fri, 14 Feb 2003 13:44:21 GMT, Chris Willig <ch...@5thelephant.com>
wrote:

Quote
>Are you showing the modal dialog in an OnExit event?

Thanks for the reply, but I just figured out what was causing it. I
had been using a procedure to force a listbox selection on the main
form (so it will highlight), and I guess the mouse_event function was
begin applied to whatever control was receiving the click, the focus
being shifted from the listbox.

procedure ListBoxForceSelect(ListBox: TListBox);
begin
  ListBox.SetFocus;
  ListBox.ItemIndex := 0;
  mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
  mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
end;

Other Threads