Solved

Disable mouse events while maximizing/minimizing

Posted on 2004-08-19
3
227 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

735 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