function OpenPageForm (PageCtrl: TcxPageControl; AClassForm: TClass; AForm: TForm; ACaption: string) : THandle;
Var
I: Integer;
Boolean: the Boolean;
The begin
Bool:=False;
With PageCtrl do begin
For I:=0 to do begin PageCount - 1
If SameText (Trim (Pages [I] Caption), Trim (ACaption)) then the begin
Bool:=True;
ActivePageIndex:=I;
Result:=ActivePage. The Tag;
end;
end;
end;
If not bool then begin
Application CreateForm (TComponentClass (AClassForm), AForm);
//Application CreateForm (TComponentClass (GetClass (' Thomefor)), AForm);
With AForm do begin
ManualDock (PageCtrl);
Caption:=ACaption;
Visible:=True;
end;
With PageCtrl do begin
ActivePageIndex:=PageCount - 1;
ActivePage. Tag:=AForm. Handle;
Result:=ActivePage. The Tag;
end;
end;
end;
How to modify to AClassForm: TClass; AForm: TForm parameters into a sting type
For example: the function OpenPageForm (PageCtrl: TcxPageControl; AClassForm: string; AForm: string ; ACaption: string) : THandle;
How to modify below, just learning Delphi for help! Thank you Daniel!
CodePudding user response:
Write similar code, but in the company, there is no such code, I have to go back to look for youI remember I was in the data inventory two values, a formClass formName;
Such as Form1 TForm1;
And then finally the form1 code, need to register Tform1
Then every time open the Tab, judge the existence of the Tab and if not, create the form,
But also a little bug, it is a Tab can't free, if free, cannot be created in the Form, may you have a better idea, of course, every time I am Tab closure, hidden Tab.
You can check the information first, if can't find, I evening go back to look for you,
CodePudding user response: