Solved

Disable mouse events while maximizing/minimizing

Posted on 2004-08-19
3
228 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP preg_replace code convert to Delphi 14 98
RESTRequest Parameter 4 81
Wincontrol not (correctly) drawn 15 59
How to insert .png images to TClientDataSet .cds file? 2 84
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…

738 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