RunPropF.pas
资源名称:delphi.rar [点击查看]
上传用户:fh681027
上传日期:2022-07-23
资源大小:1959k
文件大小:2k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit RunPropF;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- ExtCtrls, StdCtrls, Spin;
- type
- TForm1 = class(TForm)
- Edit1: TEdit;
- Label1: TLabel;
- Button1: TButton;
- ListBox1: TListBox;
- RadioButton1: TRadioButton;
- CheckBox1: TCheckBox;
- ScrollBar1: TScrollBar;
- SpinEdit1: TSpinEdit;
- ComboBox1: TComboBox;
- Bevel1: TBevel;
- procedure Button1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.DFM}
- uses
- TypInfo;
- procedure TForm1.Button1Click(Sender: TObject);
- var
- I: Integer;
- // PropInfo: PPropInfo;
- Value: Variant;
- begin
- ListBox1.Clear;
- for I := 0 to ComponentCount -1 do
- begin
- // Delphi 5 version
- Value := GetPropValue (Components[I], Edit1.Text);
- if Value <> varNULL then
- ListBox1.Items.Add (Components[I].Name + '.' +
- Edit1.Text + ' = ' + string (Value))
- else
- ListBox1.Items.Add ('No ' + Components[I].Name + '.' +
- Edit1.Text);
- // pre-Delphi 5 version, limited to strings
- {
- // get property RTTI
- PropInfo := GetPropInfo (
- Components[I].ClassInfo, Edit1.Text);
- if PropInfo = nil then
- // if not found output a message
- ListBox1.Items.Add (Descr + ' doesn''t exist')
- else if PropInfo.PropType^.Kind <> tkLString then
- // if not a strign output a message
- ListBox1.Items.Add (Descr + ' is not a string')
- else
- // show the value
- ListBox1.Items.Add (Descr + ' = [' +
- GetStrProp (Components[I], PropInfo) + ']');
- }
- end;
- end;
- end.