Home > Back-end >  Sting type into TClass; TForm, Daniel to big hand!
Sting type into TClass; TForm, Daniel to big hand!

Time:10-09

 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 you

I 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:

reference 1st floor a215107822 response:
wrote a similar code, but in the company, there is no such code, I have to go back to look for you

I 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,


Can be free, but now I don't know how to modify the above function, ask Daniel to help modify..

CodePudding user response:

AClassForm: TClass;
-- AClassForm. ClassName -- -- get the name of the class

AForm: TForm
-- AForm. Name -- -- get the Name of the form
-- AForm. ClassName -- -- get form the name of the class

CodePudding user response:

The function OpenPageForm (PageCtrl: TcxPageControl; AClassFormName: string; AForm: string; ACaption: string) : THandle;
The begin
If getClass (AClassFormName) & lt;> Nil then
The begin
.
end;
end;
Initialization
RegisterClass (Tfrom1);
Finalization
UnRegisterClass (Tfrom1);
End.
  • Related