如何得到一个一个控件(如:BUTTON,LABLEL等)的《所有属性》和所有属性的全部可能取值?多谢!!!!
解决方案 »
- 急急!截取数字问题!在线等!!!
- 光标移动问题!
- Midas问题,急需大侠拔刀
- 小问题!100分!
- 三层结构(DCOM)中,服务器执行UpdateSQL1.ExecSQL(UpdateKind)出问题?
- 如何判断一个数据库是SQL Server数据库
- 两层结构编程问题...
- 字段类型是“真假”型的。在DBGRID中怎么才能显示汉字的“真,假”而不是“TRUE,FALSE”
- **********请问各位,如何让RadioButton按扭处于灰显状态?************
- xp系统下delphi如何向打印端口LPT1按二进制循环输出0x36,0x39,0x3c;
- 写这一条SQL后运行出现怪问题?
- AssignFile(fp,pTempEquip^.savepath);? 这句话是什么意思呢?
for I:=0 to componentcount-1 do
if components[I] is TButton then
TButton(components[I]).enabled:=true;
if components[I] is TLABLEL then
TLABLEL(components[I]).enabled:=true;
如此而已
谢谢
我在设计一个在运行期可以调整得应用
var
Pclass :PTypeInfo;
PClasstd :PTypeData; ppi :PPropInfo; i, j:Integer;
ptd :PTypeData; RowIndex :Integer; tmpProps :PPropList;
tmpCount :Integer; tmpValue :Variant;
FnPropCount :Integer;
FPProps :PPropList; //当前编辑的属性列表 FControl :TObject;
begin
FControl := xx; PClass := PTypeInfo(FControl.ClassInfo);
//得到控件信息
if PClass^.Kind = tkClass then begin //如果是类
PClasstd := GetTypeData(PClass); //得到TypeData
FnPropCount := PClasstd^.PropCount;
if FnPropCount > 0 then begin
GetMem(FPProps, sizeof( PPropInfo) * FnPropCount); //分配内存 GetPropInfos(PClass, FPProps); //得到所有的属性
end;
end;
//得到第一个控件的所有属性,并放入到FPProps中
for i := 0 to FnPropCount - 1 do
begin
pPi := FpProps[i]; if Assigned(Ppi) then begin
if {inStringArray(ifo_gPropClasses, ppi.PropType^.Name)
or inStringArray(ifo_gProps, ppi.Name)} True then
begin
Self.Memo1.Lines.Add(ppi.Name + ' - ' + ppi.PropType^.Name + ' - ' + ppi.Name);
case ppi.PropType^.Kind of
tkLString:begin
tmpValue := GetStrProp(FControl, ppi.Name);
Self.Memo1.Lines.Add(' ' + tmpValue);
end;
tkInteger:begin
tmpValue := GetOrdProp(FControl, ppi.Name);
Self.Memo1.Lines.Add(' ' + IntToStr(tmpValue)); end;
tkClass:begin
if ppi.PropType^.Name = TFont.ClassName then begin
Self.Memo1.Lines.Add(' ' + '(TFont)');
end;
end;
tkEnumeration:begin
end;
end; end;
end;
end;
// Self.PropGridSelectCell(nil, FForm.sgrdEdit.Col,
// FForm.sgrdEdit.Row, tmpbool);
end;
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, StdCtrls,typinfo;type
TForm1 = class(TForm)
Button1: TButton;
insp: TStringGrid;
event: TStringGrid;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
var count,j,k,i : integer;
proplist: PPropList;//
Propinfo : PPropinfo;
begin
Count := GetTypeData(Sender.ClassInfo)^.PropCount;
if Count > 0 then
begin
// 得到属性数
GetMem(PropList, Count * SizeOf(PPropList));
try
// 得到属性
GetPropInfos(Sender.ClassInfo, PropList);
insp.RowCount:=count;
event.RowCount:=count;
j:=0;
K:=0;
for I := 0 to Count - 1 do
begin
PropInfo := PropList^[I]; case PropInfo.PropType^.kind of
tkInteger,
tkEnumeration :
insp.cells[1,j]:= inttostr(getordProp(Sender,PropInfo));
tkString,
tkLString,
tkWString :
insp.cells[1,j]:= getstrProp(Sender,PropInfo);
tkFloat :
insp.cells[1,j]:=FloattoStr(GetFloatProp(Sender,PropInfo));
tkMethod :
event.cells[1,k]:='Event';
else
insp.cells[1,i]:='TYPE'+inttostr(ord(PropInfo.PropType^.kind));
end;
if PropInfo.PropType^.kind=tkMethod then
begin
event.cells[0,k]:=PropInfo.Name;
k:=k+1
end
else
begin
insp.cells[0,j]:=PropInfo.Name;
j:=j+1;
end;
end;
insp.RowCount:=j;
event.RowCount:=k;
finally
FreeMem(PropList, Count * SizeOf(PPropList));
end;
end;
end;
您的程序仅仅遍历了所有的属性,并没有给出这些属性的所有的取值,如:windowstate的值可能是:wsNormal,wsMaximized,wsMinimized