Solved

OnMoveMove Event

Posted on 1998-12-18
7
264 Views
Last Modified: 2012-05-04
Hi

My problem is quite straight forward. I have got 2 edit boxes. if the mouse is over edit1, then it will make edit2 go RED, else it will make edit2 go WHITE.

I have used the OnMouseMove event of edit1 and make edit2 RED. All OK. then, I have used the OnMouseMove event of the form to set the edit2 to WHITE. All OK

Now, if i place edit1, close to the edge of the form, and move my mouse fast enough out of the form, edit2 remains RED, because the move movement was to fast to go through the OnMouseMove event of the form.

How do i overcome this? any better ideas anyone?

Regards
Keith
0
Comment
Question by:keithcsl
  • 4
  • 2
7 Comments
 
LVL 3

Expert Comment

by:Matvey
Comment Utility
Yes, there is a better method. There are events called CM_MOUSEENTER and CM_MOUSELEAVE. They aren't implemented in all controls, but we can make a "remix" of the edit, and use it insted. If I don't come back in 10 minutes, DIY ;-)
0
 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
Hi keithcsl,

a very easy solution is :

procedure TForm1.Edit1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
 if (X = 0) or (X=(Sender as TEdit).width) or
      (Y=0) or (Y=(Sender as TEdit).Height) then edit2.Color := clWhite
      else edit2.Color := clRed;
end;

Regards, Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
reject my answer. Matvey's solution will be better.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Expert Comment

by:Matvey
Comment Utility
Heh, OK, I'm a bit late, but here it is:

_________________________________________________________________________
unit MUEdit;

interface

uses
  Messages, Classes, Controls, StdCtrls;

type
  TMUEdit = class(TEdit)
  private
    FOnMouseEnter: TNotifyEvent;
    FOnMouseLeave: TNotifyEvent;
    procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
    procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
  published
    property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
    property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
  end;

procedure Register;

implementation

procedure TMUEdit.CMMouseEnter(var Message: TMessage);
begin
  inherited;
  if Assigned(FOnMouseEnter) then FOnMouseEnter(Self);
end;

procedure TMUEdit.CMMouseLeave(var Message: TMessage);
begin
  inherited;
  if Assigned(FOnMouseLeave) then FOnMouseLeave(Self);
end;

procedure Register;
begin
  RegisterComponents('Samples', [TMUEdit]);
end;

end.
_________________________________________________________________________

Install this component, and you have got the TMUEdit on the Samples panel. If you put it on your form, you have the OnMouseEnter and OnMouseLeave events which you can use with absolutely no farther work required. These events will be fired no meter which way the cursor enters or leavs the edit rectangle. Why the guys from Borland weren't so kind and did it themselvs??? :)

--Matvey
0
 
LVL 1

Author Comment

by:keithcsl
Comment Utility
matvey

could u post it as an answer?
thanks heaps

Regards
keith
0
 
LVL 3

Expert Comment

by:Matvey
Comment Utility
Hi Keith, glad it's one headache less!
0
 
LVL 3

Accepted Solution

by:
Matvey earned 40 total points
Comment Utility
Woopst...
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

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 The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

7 Experts available now in Live!

Get 1:1 Help Now