请问有什么办法在我自画TBUTTON时,自画的字不会被覆盖?(5分)

  • 主题发起人 主题发起人 yyyy123
  • 开始时间 开始时间
刚才在看笑话,没留意,一会再看看。[:)]
 
等你的消息!
 
看看下面的,不知道你会不会满意。我要吃饭了。

unit ButtonEx;

interface

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

type
TButtonEx = class(TButton)
private
FCanvas: TCanvas;
protected
procedure WndProc(var Message: TMessage); override;
public
constructor Create(AOwner: TComponent);override;
destructor Destroy;override;
published
{ Published declarations }
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('dwh', [TButtonEx]);
end;
constructor TButtonEx.Create(AOwner: TComponent);
begin
inherited;
FCanvas := TControlCanvas.Create;
TControlCanvas(FCanvas).Control := Self;
self.DoubleBuffered := true;
end;

destructor TButtonEx.Destroy;
begin
FCanvas.free;
inherited;
end;

procedure TButtonEx.WndProc(var Message: TMessage);
begin
inherited;
case Message.Msg of
WM_PAINT,WM_LBUTTONDOWN,WM_LBUTTONDBLCLK,WM_LBUTTONUP:
begin
FCanvas.TextRect(self.ClientRect,0,0,'hello');
end;
end;
end;

end.
 
谢谢影 子,OK了,可惜我只有5分,只好以后有给你了!
 
后退
顶部