|
| TImage og TLabel med onMouseEnter event. lavang har modtaget -10 point for dette tip Fra : lavang | Vist : 1301 gange
Dato : 01-12-04 23:28 |
|
//*******************************************************************************
//* Komponent er bestået af én TImage og én TLabel, begge har OnMouseEnter og OnMouseLeave event. *
//*******************************************************************************
unit VCImage;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
TVCImage = class(TImage)
private
fONMouseEnter :tNotifyEvent;
fONMouseLeave :tNotifyEvent;
procedure CMMouseEnter(var msg : TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var msg : TMessage); message CM_MOUSELEAVE;
protected
public
published
property OnMouseEnter : TNotifyEvent read fONMouseEnter write fONMouseEnter;
property OnMouseLeave : TNotifyEvent read fONMouseLeave write fONMouseLeave;
end;
TVCLabel = class(TLabel)
private
fOnMouseEnter : tNotifyEvent;
fOnMouseLeave : tNotifyEvent;
fHighlight : Boolean;
procedure doHighLight(HL : Boolean);
procedure CMMouseEnter(var msg : TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var msg : TMessage); message CM_MOUSELEAVE;
public
published
property Highlight : Boolean read fHighLight write doHighLight;
property OnMouseEnter : TNotifyEvent read fONMouseEnter write fONMouseEnter;
property OnMouseLeave : TNotifyEvent read fONMouseLeave write fONMouseLeave;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('TVC', [TVCImage, TVCLabel]);
end;
procedure TVCImage.CMMouseEnter(var msg : TMessage);
begin
if Assigned(fOnMouseEnter) then fOnMouseEnter(self);
end;
procedure TVCImage.CMMouseLeave(var msg : TMessage);
begin
if Assigned(fOnMouseLeave) then fOnMouseLeave(self);
end;
//-******* TVCLABEL *********************//
procedure TVCLabel.CMMouseEnter(var msg : TMessage);
begin
if Assigned(fOnMouseEnter) then fOnMouseEnter(self);
if HighLight then
begin
Font.Color := clBlue
end
end;
procedure TVCLabel.CMMouseLeave(var msg : TMessage);
begin
if Assigned(fOnMouseLeave) then fOnMouseLeave(self);
Font.Color := clWindowText;
end;
procedure TVCLabel.doHighLight(HL: Boolean);
begin
if HL <> fHighLight then
fHighLight := HL;
end;
end.
| |
| Bedømmelse
Fra : thorvald |
Dato : 02-12-04 00:42 |
| | |
| Bedømmelse
Fra : TQsen |
Dato : 02-12-04 00:57 |
| | |
| Bedømmelse
Fra : Franksp |
Dato : 02-12-04 00:22 |
| | |
| Bedømmelse
Fra : dk |
Dato : 02-12-04 00:23 |
| | |
| Du har følgende muligheder | |
|
Eftersom du ikke er logget ind i systemet, kan du ikke lave en bedømmelse til dette tip.
Hvis du ikke allerede er registreret, kan du gratis blive medlem, ved at trykke på "Bliv medlem" ude i menuen.
| |
|
|