想把开发的组件分层,定义了一个TcustomControl类父类,实现控件透明,又定义一个它的子组件,想在其中放入Label和Edit,为什么显示不出来呢 (

  • 主题发起人 主题发起人 xuegaoyili
  • 开始时间 开始时间
X

xuegaoyili

Unregistered / Unconfirmed
GUEST, unregistred user!
想把开发的组件分层,定义了一个TcustomControl类父类,实现控件透明,又定义一个它的子组件,想在其中放入Label和Edit,为什么显示不出来呢 ( 积分: 50 )<br />我在定义父类的时候,通过
procedure CMCtl3DChanged(var Message: TMessage); message CM_CTL3DCHANGED;
procedure WMEraseBkgnd(var Message: TMessage); message WM_ERASEBKGND;
procedure WMWindowPosChanging(var Message: TWMWindowPosChanging); message WM_WINDOWPOSCHANGING;
procedure CreateParams(var Params: TCreateParams); override;
procedure Paint; override;
这些从载实现的透明,再从这个父类继承一个子类,想在其中显示一个label和edit.
这时就显示不出来了...我想可能是paint事件的事..可能需要从载一下..但不能确定.
不知道有没有人能指点一下...如何显示出来
 
我在定义父类的时候,通过
procedure CMCtl3DChanged(var Message: TMessage); message CM_CTL3DCHANGED;
procedure WMEraseBkgnd(var Message: TMessage); message WM_ERASEBKGND;
procedure WMWindowPosChanging(var Message: TWMWindowPosChanging); message WM_WINDOWPOSCHANGING;
procedure CreateParams(var Params: TCreateParams); override;
procedure Paint; override;
这些从载实现的透明,再从这个父类继承一个子类,想在其中显示一个label和edit.
这时就显示不出来了...我想可能是paint事件的事..可能需要从载一下..但不能确定.
不知道有没有人能指点一下...如何显示出来
 
Label 在 OnPaint 中 TextOut 立刻就实现了.

TEdit 可不容易....
 
TGlassStyle = (
gsBlackness, gsDstInvert, gsMergeCopy, gsMergePaint, gsNotSrcCopy,
gsNotSrcErase, gsPatCopy, gsPatInvert, gsPatPaint, gsSrcAnd,
gsSrcCopy, gsSrcErase, gsSrcInvert, gsSrcPaint, gsWhiteness);

TCustomMoveControl = class(TCustomControl) //父控件,实现移动和透明,中文名称设置
private
{ Private declarations }
FCanMove:Boolean; //移动标志
FCNName:String; //中文名称

FColor: TColor;
FStyle: TGlassStyle;
FOnPaint: TNotifyEvent;

procedure SetCanMove(Value:Boolean);
procedure SetColor(Value: TColor);
procedure SetStyle(Value: TGlassStyle);
procedure SetCNName(Value:String);

procedure CMCtl3DChanged(var Message: TMessage); message CM_CTL3DCHANGED;
procedure WMEraseBkgnd(var Message: TMessage); message WM_ERASEBKGND;
procedure WMWindowPosChanging(var Message: TWMWindowPosChanging); message WM_WINDOWPOSCHANGING;

protected
{ Protected declarations }
Buffer: TBitmap;

procedure CreateParams(var Params: TCreateParams); override;
procedure Paint; override;
procedure Resize; override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
public
{ Public declarations }
constructor Create(Aowner: TComponent); override;
destructor Destroy; override;
property Canvas;

published
{ Published declarations }
property CanMove:Boolean read FCanMove write SetCanMove;
property Color: TColor read FColor write SetColor;
property CNName:String read FCNName write SetCNName;
property Style: TGlassStyle read FStyle write SetStyle default gsSrcAnd;
property OnPaint: TNotifyEvent read FOnPaint write FOnPaint;
end;

TChrEditLabel = class(TCustomMoveControl)
private
{ Private declarations }
FEdit:TEdit;
FLabel:TLabel;

procedure EditChange(Sender:TObject); //自定义edit的change事件

//下面两个获得Delphi的内部消息,鼠标进入和离开时发生
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
protected
{ Protected declarations }
procedure Paint; override;
public
{ Public declarations }
constructor Create(Aowner:TComponent);override;
Destructor Destroy;override;
published
{ Published declarations }
end;
 
后退
顶部