为什么ControlStyle包括了csFixedWidth和csFixedHeight但控件仍能改变大小?(100)

D

DF7C3

Unregistered / Unconfirmed
GUEST, unregistred user!
{为什么ControlStyle包括了csFixedWidth和csFixedHeight,但控件的width和height仍能改变?我的控件是从TCustomControl继承的。}//代码如下unit TestControl;interfaceuses SysUtils, Classes, Controls, ExtCtrls;type TTestControl = class(TCustomControl) private { Private declarations } FBevel: TBevel; FPanel: TPanel; protected { Protected declarations } public { Public declarations } constructor Create(AOwner: TComponent); override; destructor Destroy; override; published { Published declarations } property OnDblClick; end;procedure Register;implementationprocedure Register;begin RegisterComponents('Test', [TTestControl]);end;{ TTestControl }constructor TTestControl.Create(AOwner: TComponent);begin inherited; Width := 320; Height := 240; ControlStyle := ControlStyle + [csFramed, csFixedWidth, csFixedHeight, csCaptureMouse, csOpaque]; ControlStyle := ControlStyle + [csAcceptsControls, csCaptureMouse, csDesignInteractive, csClickEvents, csFramed, csSetCaption, csOpaque, csDoubleClicks, csFixedWidth, csFixedHeight, csNoDesignVisible, csReplicatable, csNoStdEvents, csDisplayDragImage, csReflector, csActionClient, csMenuEvents, csNeedsBorderPaint, csParentBackground]; FBevel := TBevel.Create(Self); FPanel := TPanel.Create(Self); FBevel.Parent := Self; FBevel.Align := alTop; FPanel.Parent := Self; FPanel.Align := alBottom;end;destructor TTestControl.Destroy;begin FPanel.Free; FBevel.Free; inherited;end;end.
 
处理一下WM_SIZE消息...public procedure WMSize(var Message: TWMSize); message WM_SIZE;...implementation...procedure TTestControl.WMSize(var Message: TWMSize);begin Width:=320; Height:=240; inherited;end;
 
csFixedWidth和csFixedHeight为什么不起作用呢?
 
TCustomControl中并未对csFixedWidth做处理做处理的是TControl
 
顶部