Вот код создания дочерней формы в главной форме
- Код: Выделить всё
procedure TfMain.Create_Forms(name_forms:string);
var
NewPage : TTabSheet;
NewToolsPan : TPanel;
NewCloseBtn : TSpeedButton;
f: Tformclass;
b: TForm;
begin
NewPage:=TTabSheet.Create(Self);
NewPage.PageControl:=PageControl1;
NewPage.Caption:=TreeView1.Selected.Text;
//-------------------------
NewToolsPan:=TPanel.Create(NewPage);
NewToolsPan.BevelOuter:=bvNone;
NewToolsPan.Color:=clForm;
NewToolsPan.Align:=alTop;
NewToolsPan.Caption:='';
NewToolsPan.Height:=20;
NewToolsPan.Parent:=NewPage;
//Close-Button
NewCloseBtn:=TSpeedButton.Create(NewPage);
NewCloseBtn.Width:=NewToolsPan.Height;
NewCloseBtn.Align:=alRight;
NewCloseBtn.Caption:='';
dm1.ImageList1.GetBitmap(4,NewCloseBtn.Glyph);
NewCloseBtn.Hint:='Закрыть вкладку';
NewCloseBtn.Tag:=integer(NewPage);
NewCloseBtn.Parent:=NewToolsPan;
NewCloseBtn.OnClick:=@OnClosePageClick;
//form-template
f:=TFormclass(findClass(name_forms));
b:=f.CreateParented(NewPage.Handle);
with b do
begin
SetStringPropertyIfExists(b,'id_tree','122');
Align:=NewPage.Align;
BorderStyle:= bsNone;
Parent:=NewPage;
Show;
PageControl1.ActivePage:=PageControl1.Pages[PageControl1.PageCount-1];
end;
end;
- Код: Выделить всё
procedure TfMain.SetStringPropertyIfExists(AComp: TObject; APropName: string;AValue: string);
var
PropInfo: PPropInfo;
TK: TTypeKind;
begin
PropInfo:=GetPropInfo(AComp, APropName);
if PropInfo <> nil then
begin
TK := PropInfo^.PropType^.Kind;
if (TK = tkString) or (TK = tkLString) or (TK = tkWString) then
SetStrProp(AComp, PropInfo, AValue);
end;
end;
объявление поля в дочерней форме
- Код: Выделить всё
private
...
id_tr :string;
...
public
property id_tree: string read id_tr write id_tr ;
end;
...
Значение id_tree в форму не передается. Функция GetPropInfo не находит property id_tree. Класс дочерней формы заключаем в {$M+} и {$M-}.
В чем дело?
