写组件时,一般会用到这两个函数1 procedure RegisterComponents(const Page: string; const ComponentClasses: array of TComponentClass);
2 procedure RegisterNoIcon(const ComponentClasses: array of TComponentClass);函数1注册的一般会出现在面板上,如可视的TEdit,不可视的TMainMenu, TActionList
函数2注册的不会出现在面板上,如TMenuItem, TAction那么在运行时,能否用代码来判断某个组件是如何注册的
实际上我的想作一个窗体编辑器,RegisterComponents的非可视组件我需要显示,而RegisterNoIcon注册的组件不需要显示,所以我希望能判断一下以便我分别处理嗯,从是否TControl判断可能行不通,例如TActionList,TAction,TMenuItem,TMainMenu都不是TControl但Delphi的IDE会在设计窗体时,显示TActionList,TMainMenu,而不显示TAction,TMenuItem,请指教,谢谢
2 procedure RegisterNoIcon(const ComponentClasses: array of TComponentClass);函数1注册的一般会出现在面板上,如可视的TEdit,不可视的TMainMenu, TActionList
函数2注册的不会出现在面板上,如TMenuItem, TAction那么在运行时,能否用代码来判断某个组件是如何注册的
实际上我的想作一个窗体编辑器,RegisterComponents的非可视组件我需要显示,而RegisterNoIcon注册的组件不需要显示,所以我希望能判断一下以便我分别处理嗯,从是否TControl判断可能行不通,例如TActionList,TAction,TMenuItem,TMainMenu都不是TControl但Delphi的IDE会在设计窗体时,显示TActionList,TMainMenu,而不显示TAction,TMenuItem,请指教,谢谢
解决方案 »
- 中秋散分帖
- delphi中开发的ocx
- 关于串口监视的问题 (delphi)
- 能否将不通路径下的文件在 ShellListView 中同时显示?怎样实现??
- 谁知道这个错误是什么意思,如何解决?
- 高手------超级简单 100相送5555555555555555555555555555555555555555555555
- 怎样使二条ADSL线路的网络资源合并起来?
- 怎样将用fastReport的报表不通过御览直接输出图片,很急啊,先谢谢各位了
- copyfile 同驱动没有问题 但从D驱到A驱 报:此功能只被此系统支持 错误 ???
- delphi videocap 显示不了usb摄像头图像
- 如何取得chart中series指针?
- 关于在dbgrid中添加记录的问题
可以考虑使用 GExperts
http://www.gexperts.org/
它有一个功能,可能得到delphi的菜单的中的Component的Configure Palette中所有可视控件图标
在http://www.gexperts.org/otafaq.html的
How can I paint the palette bitmap for a specific component
我的思路是如果能得到图标的为可视控件,得不到的为非可视控件当然,它可能可以得到所有 palette 中控件名称,那就简单了,在palette 中的为可视控件,不在palette中的为非可视控件
它支持从d6~d2010
有朋友提示我看看Lazarus,不过它的机制和Delphi还是有所区别
学习中
根据有没有left/top属性行不行?
另外,在组件面板上的不可视组件,保存在DFM中,都会保存一对left, top值,不过或许这也可以区分两种不可视组件
但你要区分的并不是可视/不可视
不过兄弟你研究可够深度的啊。
这个也不确切,某些元件也只有left, top属性还有一种方式就是通过注册表来获得哪些元件是在元件板上的,不在的就是NoIcon的
http://delphi.about.com/library/bluc/text/uc092501d.htm
A component can be almost any program element that you want to manipulate at design time. Creating a component means deriving a new class from an existing one. You can derive a new component in several ways:Modifying existing controls
Creating windowed controls
Creating graphic controls
Subclassing Windows controls
Creating nonvisual componentsThe following table summarizes the different kinds of components and the classes you use as starting points for each.Component creation starting points
To do this Start with this type
Modify an existing component Any existing component, such as TButton or TListBox, or an abstract component type, such as TCustomListBox
Create a windowed (or widget-based in CLX applications) control TWinControl (TWidgetControl in CLX applications)
Create a graphic control TGraphicControl
Subclassing a control Any Windows (VCL applications) or widget-based (CLX applications) control
Create a nonvisual component TComponent
You can also derive classes that are not components and cannot be manipulated on a form, such as TRegIniFile and TFont.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1; mycomps : tStringlist;
mynoIcons : Tlist;implementation{$R *.dfm}
// 测试注册代码
procedure TForm1.Button1Click(Sender: TObject);
begin
RegisterComponents('', [tbutton, tlabel]);
RegisterNoIcon([tcheckbox, tedit]);
end;
// 注册控件过程
procedure RegisterComponentsProc(const Page: string;
const ComponentClasses: array of TComponentClass);
var
i:Integer;
begin
for i := low(ComponentClasses) to high(ComponentClasses) do
begin
mycomps.AddObject(Page, TObject(ComponentClasses[i]));
end;
end;// 注册非可视控件过程
procedure RegisterNoIconProc(
const ComponentClasses: array of TComponentClass);
var
i:Integer;
begin
for i := low(ComponentClasses) to high(ComponentClasses) do
begin
mynoIcons.Add(ComponentClasses[i]);
end;
end;// 初始化
initialization
mycomps := tStringlist.Create;
mynoIcons := Tlist.Create;
classes.RegisterComponentsProc := RegisterComponentsProc;
classes.RegisterNoIconProc := RegisterNoIconProc;// 析构
finalization
classes.RegisterComponentsProc := nil;
classes.RegisterNoIconProc := nil;
FreeAndNil(mycomps);
FreeAndNil(mynoIcons);end.