D
DUDU
Unregistered / Unconfirmed
GUEST, unregistred user!
第一次写控件,需要从TCustomControl继承,我就自己写乐一个unit,内容如下
//没写完,还不知道怎么写
然后自己在程序里面动态创建,出错,是不是我类里面还应该写写什么,请教高人
不要笑我
unit kh_XYPlot;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls,Forms;
type
TKH_XYPlot = class;
TKH_XYPlot = class(TCustomControl)
private
FBorderStyle: TBorderStyle;
protected
procedure CreateParams(var Params: TCreateParams); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
implementation
{ TKH_XYPlot }
constructor TKH_XYPlot.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := [csAcceptsControls, csCaptureMouse, csClickEvents,
csSetCaption, csOpaque, csDoubleClicks, csReplicatable];
width:=100;
height:=100;
end;
procedure TKH_XYPlot.CreateParams(var Params: TCreateParams);
const
BorderStyles: array[TBorderStyle] of DWORD = (0, WS_BORDER);
begin
inherited CreateParams(Params);
with Params do
begin
Style := Style or BorderStyles[FBorderStyle];
if NewStyleControls and Ctl3D and (FBorderStyle = bsSingle) then
begin
Style := Style and not WS_BORDER;
ExStyle := ExStyle or WS_EX_CLIENTEDGE;
end;
WindowClass.style := WindowClass.style and not (CS_HREDRAW or CS_VREDRAW);
end;
end;
destructor TKH_XYPlot.Destroy;
begin
inherited;
end;
end.
//没写完,还不知道怎么写
然后自己在程序里面动态创建,出错,是不是我类里面还应该写写什么,请教高人
不要笑我
unit kh_XYPlot;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls,Forms;
type
TKH_XYPlot = class;
TKH_XYPlot = class(TCustomControl)
private
FBorderStyle: TBorderStyle;
protected
procedure CreateParams(var Params: TCreateParams); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
implementation
{ TKH_XYPlot }
constructor TKH_XYPlot.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := [csAcceptsControls, csCaptureMouse, csClickEvents,
csSetCaption, csOpaque, csDoubleClicks, csReplicatable];
width:=100;
height:=100;
end;
procedure TKH_XYPlot.CreateParams(var Params: TCreateParams);
const
BorderStyles: array[TBorderStyle] of DWORD = (0, WS_BORDER);
begin
inherited CreateParams(Params);
with Params do
begin
Style := Style or BorderStyles[FBorderStyle];
if NewStyleControls and Ctl3D and (FBorderStyle = bsSingle) then
begin
Style := Style and not WS_BORDER;
ExStyle := ExStyle or WS_EX_CLIENTEDGE;
end;
WindowClass.style := WindowClass.style and not (CS_HREDRAW or CS_VREDRAW);
end;
end;
destructor TKH_XYPlot.Destroy;
begin
inherited;
end;
end.