请问..我在delphi控件中做了修改,加了事件(50分)

  • 主题发起人 主题发起人 satoni
  • 开始时间 开始时间
S

satoni

Unregistered / Unconfirmed
GUEST, unregistred user!
我想知道怎么才能把我的事件加到delphi的事件可选窗口中去;;谢谢
 
写到你的控件定义的published部分(没有?就加一部分!):
TMyControl = class(TComponent)
private
...
protected
...
public
...
property .... // 外部可访问,但不显示在Object Inspector中的属性/事件
published
...
property .... // 外部可访问,也显示在Object Inspector中的属性/事件
end;
 
我写的,给你参考:
unit XdbComboBox;
interface

uses
Windows, Messages, SysUtils, Classes, Controls, StdCtrls, db, dbctrls,
DBTables, Dialogs, Forms, Graphics;
type
TXdbComboBox = class(TCustomComboBox)
private
{ Private declarations }
NeedUpDataItems : Boolean;
isLoaded : boolean;
FmouseEnter: Boolean;
FDataLink : TFieldDataLink;
FSelColor: Tcolor;
FBlendValue: Byte;
// function GetDataField: String;
GetDataField: string;
function GetDataSource: TDataSource;
procedure SetDataField(Value:String);
procedure SetDataSource(Value:TDataSource);
procedure FSetSelColor(value: TColor);
procedure FSetBlendValue(Value: Byte);
procedure CmMouseEnter(var Msg: TMessage); message CM_MOUSEENTER;
procedure CmMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
procedure WmPaint(var msg: TMessage); message WM_PAINT;
procedure CMEnter(var Msg: TCMGotFocus); message CM_ENTER;
procedure CmFocusChange(var Msg: TMessage); message CM_FOCUSCHANGED;
protected
{ Protected declarations }
Procedure DataChange(Sender:TObject);
procedure EditingChange(Sender: TObject);
procedure UpdateData(Sender:TObject);
procedure KeyPress(var Key:Char); override;
procedure DrawItem(Index: Integer; Rect: TRect;
State: TOwnerDrawState); override;
procedure DropDown; override;
procedure Click; override;
procedure CreateWnd; override;
procedure CloseUp; override;
public
{ Public declarations }
Constructor Create(AOwner:TComponent); Override;
Destructor Destroy; Override;
procedure UpDataItems;
published
{ Published declarations }
[blue] property SelColor: Tcolor Read FSelColor Write FSetselColor;
property BlendValue: byte Read FBlendvalue write FSetBlendValue;
property DataField : String read GetDataField write SetDataField;
property DataSource: TDataSource read GetDataSource write SetDataSource;[/blue] property AutoComplete default True;
property AutoDropDown default False;
property Style; {Must be published before Items}
property Color;
property Ctl3D;
property DragCursor;
property DragKind;
property DragMode;
property DropDownCount;
property Enabled;
property Font;
property ImeMode;
property ImeName;
property ItemHeight;
property MaxLength;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property Sorted;
property TabOrder;
property TabStop;
property Text;
property Visible;
property OnChange;
property OnClick;
property OnCloseUp;
property OnContextPopup;
property OnDblClick;
property OnDrawItem;
property OnDropDown;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMeasureItem;
property OnSelect;
end;
 
我不是自己新加控件.我是改delphi的控件;dbgrid;我也加到了publish里面,但是不显示
 
不行的,因为Delphi不会用到dbgrid的原代码用到(Dbgrid编译近包里面),你修改了也没有用,写错了也不会报错。
你只能另存,将DBgrid的类名称改为另外的名称 例如:xDbGrid;安装xDbGrid。
 
我加了事件可是有用的啊..只是不显示出来罢了...
 
satoni:你是不是把dbgrid的源码改了,加到你的工程里?
 
对啊。。我吧dbgrid的源码改了。也重新编译了delphi的缺省dpk,我能用我加的事件;但是我想让事件显示在Object Inspector中,应该怎么办
 
我定义事件的例子:
TAngleDivideEvent = procedure(Sender: TObject; Angle1, Angle2: Single; Azithum : array of Single) of object;
private
FOnAngleDivide : TAngleDivideEvent;

property OnAngleDivide : TAngleDivideEvent read FOnAngleDivide write FOnAngleDivide;
在激发事件时:
if not Loading then if Assigned(FOnAngleDivide) then FOnAngleDivide(Self, Angle1, Angle2, AziVal);

 
你最好继承dbgrid,自己做控件包;
一方面不方便,二来通用性有问题。
 
yostgxf:你说的和我问的有点对不上啊...

apw:我也知道新加控件好,但是我只是在dbgrid上改一个标题双击事件,重新继承做控件碰上点麻烦;由于中间我用的几个属性又是dbgrid继承别的,老是出问题..所以我想采取修改dbgrid的方式,反正也没怎么大改,就想在object Inspector中显示而已,没别的办法吗?
 
自己顶一下,分还没送出去,回答过的老大继续关注一下
 
后退
顶部