Solved

Disable mouse events while maximizing/minimizing

Posted on 2004-08-19
3
226 Views
Last Modified: 2010-04-05
I use the OnMouseDown, OnMouseMove and OnMouseUp events to draw lines on a TImage. If I maximize/minimize the form it happens that an OnMouseMove event is fired without a corresponding OnMouseDown etc.
Is there a way to disable the events before resizing and enable them after resizing has finished?

Thanks!
0
Comment
Question by:__alex
3 Comments
 
LVL 4

Expert Comment

by:Colin_Dawson
ID: 11840317
You could add a little extra code to see if the position of the event is within the canvas of the TImage.  It should have the same effect.
0
 
LVL 7

Accepted Solution

by:
LRHGuy earned 200 total points
ID: 11841627
Here's what worked for me...

tForm2=class...
 private
   fMouseOK:boolean;
...

procedure TForm2.FormCreate(Sender: TObject);
begin
  fmouseok:=true;
end;

procedure TForm2.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if fmouseok then begin
   // do work here
  end;
  fmouseok:=true;
end;

procedure TForm2.WMSize(var Message: TWMSize);
begin
  fMouseOK:=false;
  inherited;
end;


By using a "flag" to control when the mouse move is valid...by necessity, the mouse "moves" when the window resizing, at least the coordinates relative to the form. the WMsize turns off the mouse move...at the end of the resize, the mouse is "moved", and we turn it back on after the first call. Works here!
0
 
LVL 2

Author Comment

by:__alex
ID: 11849648
Awesome, thanks!
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question