procedure TForm1.WndProc(var Message: TMessage);
begin
if Message.LParam = Longint(SpeedButton1) then
begin
if Message.Msg = CM_MOUSELEAVE then // mouse out
SpeedButton1.Font.Color := clBlack;
if Message.Msg = CM_MOUSEENTER then //into mouse
SpeedButton1.Font.Color := clRed;
end;
버튼을 SpeedButton 으로 바꾸시구요.
간단한 서브클래싱을 하시면 됩니다.
그럼~ 항상 즐거운 프로그래밍 하시길~~
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, ExtCtrls, Buttons;
type
TForm1 = class(TForm)
Button1: TButton;
Timer1: TTimer;
SpeedButton1: TSpeedButton;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
procedure WndProc(var Message: TMessage); override;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.WndProc(var Message: TMessage);
begin
if Message.LParam = Longint(SpeedButton1) then
begin
if Message.Msg = CM_MOUSELEAVE then // mouse out
SpeedButton1.Font.Color := clBlack;
if Message.Msg = CM_MOUSEENTER then //into mouse
SpeedButton1.Font.Color := clRed;
end;
inherited WndProc(Message);
end;