Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is there an MouseOver and MouseOut event in Delphi.

1,953 views
Skip to first unread message

ibrahim

unread,
Apr 23, 2000, 3:00:00 AM4/23/00
to
I want to use a MouseOver even on my form, so that when the user takes the
mouse over a a label of button, the color of the font changes.

Thanks in advance.
Ibrahim.


Peter Jukel

unread,
Apr 23, 2000, 3:00:00 AM4/23/00
to
<<ibrahim:

I want to use a MouseOver even on my form, so that when the user takes the
mouse over a a label of button, the color of the font changes.
>>

There not an OnMouseOver as such, but there is an event called OnMouseMove.
OnMouseOut does not either exist.

I wonder if it would be a good idea to add such events, because they are
useful.

Regards

Peter


Johannes Berg

unread,
Apr 23, 2000, 3:00:00 AM4/23/00
to
> I wonder if it would be a good idea to add such events, because they are
> useful.

not that hard, just derive a custom component and handle CM_MouseEnter and
CM_MouseLeave

johannes
--
Please reply in this newsgroup only
- SIP solutions -
http://www.sipsolutions.de/


Peter Jukel

unread,
Apr 23, 2000, 3:00:00 AM4/23/00
to
<<Johannes:

not that hard, just derive a custom component and handle CM_MouseEnter and
CM_MouseLeave
>>

Thanks, Johannes, but I meant Borland adding them to TForm.

Regards

Peter


ibrahim

unread,
Apr 23, 2000, 3:00:00 AM4/23/00
to
Thanks Johannes, but I was thinking of something simple. I am actually a
beginner.
If its possible for you, can you tell me how to derive a custom component.

Thanks again.
Ibrahim.
Johannes Berg wrote in message <39033CE9...@gmx.net>...


>> I wonder if it would be a good idea to add such events, because they are
>> useful.
>

>not that hard, just derive a custom component and handle CM_MouseEnter and
>CM_MouseLeave
>

Johannes Berg

unread,
Apr 23, 2000, 3:00:00 AM4/23/00
to
> Thanks, Johannes, but I meant Borland adding them to TForm.

hmm, actually, why not TWinControl?

Johannes Berg

unread,
Apr 24, 2000, 3:00:00 AM4/24/00
to
{
(could you please trim your quotes next time?)

> Thanks Johannes, but I was thinking of something simple. I am actually a
> beginner.
> If its possible for you, can you tell me how to derive a custom component.

You wanted a TLabel, right?
Create a new component by going File|New|component, name it TInOutLabel or
whatever you like, and base it on TLabel, fill in a proper filename and hit
OK.

Fill it like this:
}
unit uInOutLabel;
// created by Johannes Berg (joha...@sipsolutions.de)
// might not compile...

interface
uses ...;

type
TInOutLabel = component(TLabel)
private

FOnMouseEnter,
FOnMouseLeave : TNotifyEvent;
// if you leave out these lines Delphi will do its magic and
// stick them in when you hit CTRL-SHIFT-C (see below) ;-)


protected
procedure CMMouseEnter (var msg:tmessage); message cm_mouseenter;
procedure CMMouseLeave (var msg:tmessage); message cm_mouseleave;

published
property OnMouseEnter : TNotifyEvent read FOnMouseEnter
write FOnMouseEnter;
property OnMouseLeave : TNotifyEvent read FOnMouseLeave
write FOnMouseLeave;
// now put your cursor here and hit CTRL-SHIFT-C,
// you will automatically get the procedures CMMouseEnter&CMMouseLeave
// in the implementation section
end;

implementation

procedure TInOutLabel.CMMouseEnter(var msg:tmessage);
begin
if Assigned(FOnMouseEnter) then FOnMouseEnter(self);
end;

procedure TInOutLabel.CMMouseEnter(var msg:tmessage);
begin
if Assigned(FOnMouseLeave) then FOnMouseLeave(self);
end;

end.

Ok, since I put { } around the top you might as well just copy the whole post
I just wrote and save it as your unit <g>

0 new messages