使用WndProc来处理消息

时间:2010-02-03 12:46:30  来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:oc(var Message : TMessage); override; end; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM}
  正文:unit Unit1;

interface

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

type

TURLLabel = class(TLabel)
procedure WndProc(var Message : TMessage); override;
end;

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

{ TURLLabel }

procedure TURLLabel.WndProc(var Message: TMessage);
begin
  if (Message.Msg = CM_MOUSELEAVE) then
  begin
    Font.Color := clWindowText;
    Font.Style := Font.Style - [fsUnderline];
  end;
  if (Message.Msg = CM_MOUSEENTER) then
  begin
    Font.Color := clBlue;
    Font.Style := Font.Style + [fsUnderline];
  end;
  inherited WndProc(Message);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  with TURLLabel.Create(Self) do
    begin
      Parent := Self;
      Left := 10;
      Top := 10;
      caption := 'www.tommstudio.com';
      Cursor := crHandPoint;
    end;
  end;
  
end.
使用WndProc来处理消息》由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Language/Delphi/12749.html


关键字:

关于《使用WndProc来处理消息》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td