简单但不容易的问题!(100分)

Y

yhv

Unregistered / Unconfirmed
GUEST, unregistred user!
如果我知道某个控件的名字,但不知该控件在哪个页面内,如何查询到?
不容易吧,谢谢您。
 
delphi的IDE信息保存在注册表里
你可以打开:HKEY_CURRENT_USER/Software/Borland/Delphi/6.0/Palette
来看看
如果还不知道怎样做的话
我明天做个例子给你
 
菜单中Component中install packages.
在话框中然后选择一个,点component按钮!自已找吧(知道名字的兄弟)
 
一个一个找阿,笨方法,但一定行,哈哈
 
Componet->Config Palette->把Palette左边的滚动条滑到最下面,点[All]->点右边的"Name"栏,
则所有控件按ABCD的字母顺序排下来->从上到下根据字母顺序很容易就会找到你要的控件->
再看一下同一行里Page栏的名字,就知道了是在Standard还是win32还是System等等页里了。
 
逐页找,用鼠标指向控件,会显示名称的。
 
看了别人的回帖
倒不明白你要的是什么
在DELPHI的IDE中查
还是自己想在程序中查??

如果是后面的
我可以给个例子
 
我一般都 用sandao的方法
 
view->component list
然后输入控件名字就好了
 
view->component list
然后输入控件名字就好了

例如TButton
 
下面的代码可以在edit1中输入要查询的控件名
可以在ListView1中列出

unit Unit1;

interface

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

type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
ListView1: TListView;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

uses Registry;
var Palette_List:TStringList;
{$R *.DFM}

//------------------------------------------------------
{下面这个过程是分割字符串.例如对于
s:='ABC;DE;FGHI;JK';
sList:=SplitString(s,';');
这样sList的内容为: ABC
DE
FGHI
JK
}
function SplitString(const source,ch:string):TStringlist;
var
temp:string;
i:integer;
begin
result:=tstringlist.Create;
temp:=source;
i:=pos(ch,source);
while i<>0 do
begin
result.Add(copy(temp,0,i-1));
delete(temp,1,i);
i:=pos(ch,temp);
end;
result.Add(temp);
end;
//------------------------------------------------------

procedure TForm1.Button1Click(Sender: TObject);
var i,j,iIndex:integer;
sPalette,sPaletteValue,sFind:String;
Index_List:TStringlist;
s,p,K:String;
begin
j:=0;
sFind:= UpperCase(Edit1.text);
iIndex:=-1;
ListView1.Items.Clear;
Palette_List:=TStringlist.Create;
Index_List:=TStringlist.Create;
with Tregistry.create do
try
RootKey:=HKEY_CURRENT_USER;
OpenKey('Software/Borland/Delphi/5.0/Palette',false);
GetValueNames(Palette_List);
for i:=0 to Palette_List.count-1 do
begin
sPalette:= Palette_List.Strings;
sPaletteValue:=UpperCase(ReadString(sPalette));

if Pos(sFind,sPaletteValue)>0 then
begin
Index_List:=SplitString(sPaletteValue,';');
{ iIndex:=Index_List.IndexOf(Edit1.text);
不能用上面这句,如果这样要全部匹配 }
for j:=0 to Index_List.Count-1 do
if Pos(sFind,Index_List.Strings[j])>0 then
begin
iIndex:= j+1;//控件在控件栏的索引号以1起
with ListView1.Items.Add do begin
S := sPalette;
P := Index_List.Strings[j];
k := inttostr(iIndex);
Caption := S; //控件栏
SubItems.Add(P); //匹配控件名
SubItems.Add(k); //索引号
end;
end; //end for j:=0
end; //end if Pos
end; //end for i:=0

if iIndex=-1 then
MessageDlg('在控件栏中没有找到控件:'+Edit1.text, mtError, [mbOK], 0);
finally
Palette_List.Free;
Index_List.Free;
free;
end;
end;
//------------------------------------------------------

end.
 
顶部