自製VCL元件如何加入事件程式?? |
尚未結案
|
jeffreck
高階會員 發表:247 回覆:340 積分:197 註冊:2003-01-23 發送簡訊給我 |
各位前輩請教一下: 自製VCL元件如何加入事件程式??
如在OnEnter加入程式,要如何做??
另外目前市面上介紹vcl的書好像不多??可否介紹幾本 非常非常的謝謝你,因為有你這世界變的更美好 ☆ ^_^ ☆
°∴°﹒☆°.﹒‧°∴°﹒°.﹒‧°∴°﹒
﹒‧°∴°﹒☆°.﹒‧°∴°﹒°.﹒‧°∴°﹒﹒‧°∴°﹒☆°. 目前程式如下:
unit JKDBDateEdit; interface uses
SysUtils, Messages,Dialogs,Classes, Controls, StdCtrls, Mask, DBCtrls,Graphics; type TJKDataType = (JkDateTiem, JkString, JkNumber);
TJKDataTypes = set of TJKDataType;
TJKDBDateEdit = class(TDBEdit)
procedure TJKDBDateEdit.EditEnter(Sender: TObject); private
{ Private declarations }
FjkAllowAddNew :Boolean;
FjkAllowEdit :Boolean;
FJKDataType : TJKDataType;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations } Property jkAllowAddNew : Boolean Read FjkAllowAddNew
Write FjkAllowAddNew;
Property jkAllowEdit :Boolean Read FjkAllowEdit
Write FjkAllowEdit;
Property JKDataType:TJKDataType read FJKDataType Write FJKDataType ;
end; procedure Register; implementation procedure EditEnter(Sender: TObject);
begin
showmessage('sdf');
end; procedure Register;
begin
RegisterComponents('JkDBControls', [TJKDBDateEdit]);
end; end.< >< >
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
For your case, you may want to override the DoEnter method., e.g.
unit JKDBDateEdit; interface uses SysUtils, Messages,Dialogs,Classes, Controls, StdCtrls, Mask, DBCtrls,Graphics; type TJKDataType = (JkDateTiem, JkString, JkNumber); TJKDataTypes = set of TJKDataType; TJKDBDateEdit = class(TDBEdit) private { Private declarations } FjkAllowAddNew :Boolean; FjkAllowEdit :Boolean; FJKDataType : TJKDataType; protected { Protected declarations } procedure DoEnter; override; public { Public declarations } published { Published declarations } Property jkAllowAddNew : Boolean Read FjkAllowAddNew Write FjkAllowAddNew; Property jkAllowEdit :Boolean Read FjkAllowEdit Write FjkAllowEdit; Property JKDataType:TJKDataType read FJKDataType Write FJKDataType; end; procedure Register; implementation procedure TJKDBDateEdit.DoEnter; begin showmessage('sdf'); inherited; end; procedure Register; begin RegisterComponents('JkDBControls', [TJKDBDateEdit]); end; end.If you want to create custom event (visible in Objec Inspector), e.g. TExample = class(TComponent) private FExEvent: TNotifyEvent; published property ExEvent: TNotifyEvent read FExEvent write FExEvent default nil; end;And you should always initialize the variables first ( |
pgdennis
資深會員 發表:41 回覆:526 積分:443 註冊:2002-05-23 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |