Solved

Disable mouse events while maximizing/minimizing

Posted on 2004-08-19
3
224 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

705 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now