我想重构一个KSDev ThemeEngine.v6.0 下的一个TTeComboBox,遇到点小问题:((100分)

  • 主题发起人 主题发起人 jiang_yun_2005
  • 开始时间 开始时间
J

jiang_yun_2005

Unregistered / Unconfirmed
GUEST, unregistred user!
我想重写onKeyUp事件,可是老出错,请帮忙看一下。
unit TecdsComboBox;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, te_controls;

type
TTecdsComboBox = class(TTeComboBox)
private
{ Private declarations }
FOnKeyPress : TKeyPressEvent;
protected
{ Protected declarations }
procedure KeyPress;Override;
public
{ Public declarations }
constructor Create(AOwner: TComponent);override;
destructor Destroy; override;
published
{ Published declarations }
property OnKeyPress :TKeyPressEvent read FOnKeyPress write FOnKeyPress;
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('自定义', [TTecdsComboBox]);
end;

Constructor TTecdsComboBox.Create(AOwner: TComponent);
Begin
inherited Create(AOwner);
End;

Destructor TTecdsComboBox.Destroy;
Begin
inherited Destroy;
End;

procedure TTeScdComboBox.KeyPress();
begin
showmessage('adfd');
inherited KeyPress;
if Assigned(FOnKeyPress) then FOnKeyPress(Self);
end;



end.
 
试试看重写Twincontrol的处理WM_KEYDOWN消息的函数
 
unit unit2;

interface

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

type
TTecdsComboBox = class(TComboBox)
private
{ Private declarations }
FOnKeyPress : TKeyPressEvent;
protected
{ Protected declarations }
procedure KeyPress(var Key: Char);Override;
public
{ Public declarations }
constructor Create(AOwner: TComponent);override;
destructor Destroy; override;
published
{ Published declarations }
property OnKeyPress :TKeyPressEvent read FOnKeyPress write FOnKeyPress;
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('自定义', [TTecdsComboBox ]);
end;

Constructor TTecdsComboBox .Create(AOwner: TComponent);
Begin
inherited Create(AOwner);
End;

Destructor TTecdsComboBox .Destroy;
Begin
inherited Destroy;
End;

procedure TTecdsComboBox.KeyPress(var Key: Char);
begin
showmessage('adfd');
inherited;
if Assigned(FOnKeyPress) then FOnKeyPress(self,Key);
end;
 
to Murray
谢谢了onkeypress搞定了,再帮我看看onexit吧,
报错,TecdComboBox.pas(25): Method 'Exit' not found in base class;
 
unit unit2;

interface

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

type
TTecdsComboBox = class(TComboBox)
private
{ Private declarations }
FOnKeyPress : TKeyPressEvent;
FOnExit : TNotifyEvent;
protected
{ Protected declarations }
procedure KeyPress(var Key: Char);Override;
procedure DoExit;dynamic;
public
{ Public declarations }
constructor Create(AOwner: TComponent);override;
destructor Destroy; override;
published
{ Published declarations }
property OnKeyPress :TKeyPressEvent read FOnKeyPress write FOnKeyPress;
property OnExit: TNotifyEvent read FOnExit write FOnExit;
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('自定义', [TTecdsComboBox ]);
end;

Constructor TTecdsComboBox .Create(AOwner: TComponent);
Begin
inherited Create(AOwner);
End;

Destructor TTecdsComboBox .Destroy;
Begin
inherited Destroy;
End;

procedure TTecdsComboBox.DoExit;
begin
inherited;
if Assigned(FOnExit) then FOnExit(self);
end;

procedure TTecdsComboBox.KeyPress(var Key: Char);
begin
showmessage('adfd');
inherited;
if Assigned(FOnKeyPress) then FOnKeyPress(self,Key);
end;
end.
 
这个地方不对的:procedure DoExit;dynamic;我改成这个就对了procedure DoExit;override;
你看是不是这样的?
 
是的,我写错了.呵呵
 
Murray, 谢谢了
 
接受答案了.
 
后退
顶部