Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help using onMouseMove

Status
Not open for further replies.

LordFett

Technical User
Oct 6, 2001
1
US
I am getting back into Delphi programming (havent used it since Delphi 2 was fairly new)and need a little refreshing.

In a program that I am writing I have a piece that uses onMouseMove to set a Visible property of a shape (that is false by default) to true when the mouse is over an edit box. How to have if reset back to false when the mouse is moved away again?
 
You need a new event for that since there isnt an event
that passes such behavior:

I needed it for a button once and this is the code I used
for the new events (OnMouseEnter & OnMouseLeave), maybe you
use it for your edit box ....

Code:
unit CWMooButton1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TCWMooButton1 = class(TButton)
  private
    fOnMouseEnter: TNotifyEvent;
    fOnMouseLeave: TNotifyEvent;
    procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
    procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
  protected
    { Protected declarations }
  public
    { Public declarations }
  published
    property OnMouseEnter: TNotifyEvent read fOnMouseEnter write fOnMouseEnter;
    property OnMouseLeave: TNotifyEvent read fOnMouseLeave write fOnMouseLeave;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('CWCon', [TCWMooButton1]);
end;

{ TmyButton }
// When mouse enter, this procedure will be executed
procedure TCWMooButton1.CMMouseEnter(var Message: TMessage);
begin
  if assigned(fOnMouseEnter) then fOnMouseEnter(self);
end;
// When mouse exit, this procedure will be executed
procedure TCWMooButton1.CMMouseLeave(var Message: TMessage);
begin
  if assigned(fOnMouseLeave) then fOnMouseLeave(self);
end;

end.

I hope this helps,

BobbaFet Everyone has a right to my opinion.
E-mail me at cwcon@programmer.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top