Определить и выставить значение текстового свойства
Определить и выставить значение текстового свойства
unit StrForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
TForm1 = class (TForm)
ButtonGet: TButton;
EditProperty: TEdit;
Label1: TLabel;
Bevel1: TBevel;
ButtonTrial: TButton;
Label2: TLabel;
LabelResult: TLabel;
ButtonSet: TButton;
Label3: TLabel;
EditValue: TEdit;
procedure ButtonGetClick(Sender: TObject);
procedure ButtonSetClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end ;
var
Form1: TForm1;
implementation
{$R *.DFM}
uses
TypInfo;
procedure TForm1.ButtonGetClick(Sender: TObject);
var
PropInfo: PPropInfo;
begin
if not Assigned (ButtonTrial) then
ShowMessage ('The button has been renamed')
else
begin
PropInfo := GetPropInfo (
ButtonTrial.ClassInfo, EditProperty.Text);
if PropInfo <> nil then
if PropInfo^.PropType^.Kind =
tkLString then
LabelResult.Caption :=
GetStrProp (ButtonTrial, PropInfo)
else
ShowMessage ('Not a string property')
else
ShowMessage ('Property doesn''t exist');
end ;
end ;
procedure TForm1.ButtonSetClick(Sender: TObject);
var
PropInfo: PPropInfo;
begin
if not Assigned (ButtonTrial) then
ShowMessage ('The button has been renamed')
else
begin
PropInfo := GetPropInfo (
ButtonTrial.ClassInfo, EditProperty.Text);
if PropInfo <> nil then
if PropInfo^.PropType^.Kind =
tkLString then
SetStrProp (ButtonTrial, PropInfo, EditValue.Text)
else
ShowMessage ('Not a string property')
else
ShowMessage ('Property doesn''t exist');
end ;
end ;
end .
Загрузить весь проект
Статья Определить и выставить значение текстового свойства раздела Компоненты и Классы Свойства и События может быть полезна для разработчиков на Delphi и FreePascal.
Комментарии и вопросы
Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.
:: Главная :: Свойства и События ::