控件如何才有的形状?(50分)

  • 主题发起人 主题发起人 yzf1974
  • 开始时间 开始时间
Y

yzf1974

Unregistered / Unconfirmed
GUEST, unregistred user!
我想从从TWinControl开始,定制我的ScrollBar,如何定制它的外形?说是控件在设计期间
读写DMF文件,我看了TScrollBar = class(TWinControl)的那一段代码和 TScrollBar在DMF文件中的记录,不知道那几句对TScrollBar的形状起作用。我要是该变TScrollBar的滑块的形状,并且只能从TWinControl开始继承,该如何办?
 
找书看了,原来要重载控件的paint方法,作了一个控件,确实是那么回事
 
我又看了TScrollBar的vcl源码,还是不知道该控件的在设计期间和运行期都有的小滑块是
什么时候画的,是那些代码控制画的,我没有发现ScrollBar重载TWinControl的paint方法啊!请各位帮忙解答解答,谢谢了啊!
下面的申明中,是在什么地方画小滑块的?
TScrollBar = class(TWinControl)
private
FKind: TScrollBarKind;
FPosition: Integer;
FMin: Integer;
FMax: Integer;
FPageSize: Integer;
FRTLFactor: Integer;
FSmallChange: TScrollBarInc;
FLargeChange: TScrollBarInc;
FOnChange: TNotifyEvent;
FOnScroll: TScrollEvent;
procedure DoScroll(var Message: TWMScroll);
function NotRightToLeft: Boolean;
procedure SetKind(Value: TScrollBarKind);
procedure SetMax(Value: Integer);
procedure SetMin(Value: Integer);
procedure SetPosition(Value: Integer);
procedure SetPageSize(Value: Integer);
procedure CNHScroll(var Message: TWMHScroll); message CN_HSCROLL;
procedure CNVScroll(var Message: TWMVScroll); message CN_VSCROLL;
procedure CNCtlColorScrollBar(var Message: TMessage); message CN_CTLCOLORSCROLLBAR;
procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
procedure Change; dynamic;
procedure Scroll(ScrollCode: TScrollCode; var ScrollPos: Integer); dynamic;
public
constructor Create(AOwner: TComponent); override;
procedure SetParams(APosition, AMin, AMax: Integer);
published
property Align;
property Anchors;
property BiDiMode;
property Constraints;
property Ctl3D;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Kind: TScrollBarKind read FKind write SetKind default sbHorizontal;
property LargeChange: TScrollBarInc read FLargeChange write FLargeChange default 1;
property Max: Integer read FMax write SetMax default 100;
property Min: Integer read FMin write SetMin default 0;
property PageSize: Integer read FPageSize write SetPageSize;
property ParentBiDiMode;
property ParentCtl3D;
property ParentShowHint;
property PopupMenu;
property Position: Integer read FPosition write SetPosition default 0;
property ShowHint;
property SmallChange: TScrollBarInc read FSmallChange write FSmallChange default 1;
property TabOrder;
property TabStop default True;
property Visible;
property OnContextPopup;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnScroll: TScrollEvent read FOnScroll write FOnScroll;
property OnStartDock;
property OnStartDrag;
end;

TStaticBorderStyle = (sbsNone, sbsSingle, sbsSunken);

TCustomStaticText = class(TWinControl)
private
FAlignment: TAlignment;
FAutoSize: Boolean;
FBorderStyle: TStaticBorderStyle;
FFocusControl: TWinControl;
FShowAccelChar: Boolean;
procedure CMDialogChar(var Message: TCMDialogChar); message CM_DIALOGCHAR;
procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
procedure CMTextChanged(var Message: TMessage); message CM_TEXTCHANGED;
procedure AdjustBounds;
procedure SetAlignment(Value: TAlignment);
procedure SetBorderStyle(Value: TStaticBorderStyle);
procedure SetFocusControl(Value: TWinControl);
procedure SetShowAccelChar(Value: Boolean);
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure Loaded; override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure SetAutoSize(Value: Boolean); override;
property Alignment: TAlignment read FAlignment write SetAlignment
default taLeftJustify;
property AutoSize: Boolean read FAutoSize write SetAutoSize default True;
property BorderStyle: TStaticBorderStyle read FBorderStyle
write SetBorderStyle default sbsNone;
property FocusControl: TWinControl read FFocusControl write SetFocusControl;
property ShowAccelChar: Boolean read FShowAccelChar write SetShowAccelChar
default True;
public
constructor Create(AOwner: TComponent); override;
end;
 
他应该是用了WINDOWS的标准滚动条控件,就象EDIT的控件
 
完全可以自己做一个全新的,响应滚动条需要的那几个消息就可以了.
 
后退
顶部