如题,扩展的功能只是在DBGridEh上加一个右键功能,点右键会弹出来一个菜单(由我来设计具体的功能),我要把它做成一个控件,然后安装到delphi里面,在组件板上有个小图标,怎么做呀?我现在的进度已经到了:component中new component,配好了选项,并且自动生成了代码!如下:
unit DBGridEhHw;interfaceuses
Windows, Messages, SysUtils, Classes, Controls, Grids, DBGridEh;type
TDBGridEhHw = class(Tdbgrideh)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('ehlib', [TDBGridEhHw]);
end;end.
下面就不知道怎么做了!
应该怎么写呀!现在我要在里面加一个TPopupMenu,好让DBGridEh有右键功能,怎么做呀,大家帮帮我!帮我把代码完善一下,谢谢!
unit DBGridEhHw;interfaceuses
Windows, Messages, SysUtils, Classes, Controls, Grids, DBGridEh;type
TDBGridEhHw = class(Tdbgrideh)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('ehlib', [TDBGridEhHw]);
end;end.
下面就不知道怎么做了!
应该怎么写呀!现在我要在里面加一个TPopupMenu,好让DBGridEh有右键功能,怎么做呀,大家帮帮我!帮我把代码完善一下,谢谢!
解决方案 »
- delphi 調用matrix問題
- 麻烦帮看看这个循环错在哪里了,感谢
- 在DBGRID里面鼠标滚动时,如果让与数据库关联的DBEDIT的值也跟着变动.
- 请问那位知道对Serv-U编程的接口函数,我想用自己的程序添加一个用户并指定该用户的目录。能完成添加用户,用Windows自带的FTP也行。
- 操作http://..../123.mdb 这样的数据库可以吗?
- 有谁动态创建过TDateTimePicker》》》》》》》》》》》》》》》》》》》》》》》》
- 怎么让程序中的所有字体都是宋体呢?
- 如何模拟鼠标行为?
- 如何直接删除文件夹以及里面的所有文件?(没有子文件夹)
- 调查一下:各位靠Delphi吃饭的兄弟姐妹,都是用Delphi来做什么活?
- 在线等,如何获知一个文件的创建时间!!
- 这样的查询是用一个组件好还是用两个组见好呢?
PopupMenu:TPopupMenu;
MenuItem: TMenuItem;
MenuItemLine: TMenuItem;
begin if not (csDesigning in self.ComponentState)then
begin if FDBGridEh.PopupMenu=nil then
begin
PopupMenu:=TPopupMenu.Create(self); //创建快捷菜单
FDBGridEh.PopupMenu:=PopupMenu;
end; MenuItem:=TMenuItem.Create(self); //创建菜单项
MenuItem.OnClick:=MemuItemOnClick; //自己在上面声明一个OnClick过程,具体要完成的功能写在里面
MenuItem.Caption:='设置...';
MenuItemLine:=TMenuItem.Create(self); //创建菜单项
MenuItemLine.Caption:='-';
FDBGridEh.PopupMenu.Items.Insert(0,MenuItemLine);//菜单项位置
FDBGridEh.PopupMenu.Items.Insert(0,MenuItem);
end;
你可以把这些写到OnCreate事件中.
unit DBGridEhHw;interfaceuses
Windows, Messages, SysUtils, Classes, Controls, Grids, DBGridEh;type
TDBGridEhHw = class(Tdbgrideh)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: Tdbgrideh); override;
published
{ Published declarations }
end;procedure Register;implementationconstructor TDBGridEhHw.Create(AOwner: Tdbgrideh);
var
PopupMenu: TPopupMenu;
MenuItem: TMenuItem;
MenuItemLine: TMenuItem;
procedure PrintOnClick;
begin
showmessage('print');
end;
begin
inherited Create(AOwner);
if not (csDesigning in self.ComponentState) then
begin
if AOwner.PopupMenu = nil then
begin
PopupMenu := TPopupMenu.Create(self); //创建快捷菜单
AOwner.PopupMenu := PopupMenu;
end; MenuItem := TMenuItem.Create(self); //创建菜单项
MenuItem.OnClick := PrintOnClick; //自己在上面声明一个OnClick过程,具体要完成的功能写在里面
MenuItem.Caption := '设置...';
MenuItemLine := TMenuItem.Create(self); //创建菜单项
MenuItemLine.Caption := '-';
AOwner.PopupMenu.Items.Insert(0, MenuItemLine); //菜单项位置
AOwner.PopupMenu.Items.Insert(0, MenuItem);
end;
end;procedure Register;
begin
RegisterComponents('ehlib', [TDBGridEhHw]);
end;
end.
Windows, Messages, SysUtils, Classes, Controls, Grids, DBGridEh;type
TDBGridEhHw = class(Tdbgrideh)
private
{ Private declarations }
protected
{ Protected declarations }
procedure PrintOnClick(Sender:TObject);
public
{ Public declarations }
constructor Create(AOwner: TObject); override;
published
{ Published declarations }
end;procedure Register;implementationprocedure TDBGridEhHw.PrintOnClick(Sender:TObject);
begin
showmessage('print');
end;constructor TDBGridEhHw.Create(AOwner: Tdbgrideh);
var
PopupMenu: TPopupMenu;
MenuItem: TMenuItem;
MenuItemLine: TMenuItem;
begin
inherited Create(AOwner);
if not (csDesigning in self.ComponentState) then
begin
if self.PopupMenu = nil then
begin
PopupMenu := TPopupMenu.Create(self); //创建快捷菜单
self.PopupMenu := PopupMenu;
end; MenuItem := TMenuItem.Create(self); //创建菜单项
MenuItem.OnClick := PrintOnClick; //
MenuItem.Caption := '打印...';
MenuItemLine := TMenuItem.Create(self); //创建菜单项
MenuItemLine.Caption := '-';
self.PopupMenu.Items.Insert(0, MenuItemLine); //菜单项位置
self.PopupMenu.Items.Insert(0, MenuItem);
end;
end;procedure Register;
begin
RegisterComponents('ehlib', [TDBGridEhHw]);
end;
end.
constructor Create(AOwner: TComponent); override;