Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to avoid bloated code for tabsheets 1

Status
Not open for further replies.

NCAnnie

Programmer
May 10, 2004
1
IE
I am rewriting an application which used lots of forms (using showmodal etc). Now I want the forms to be represented on tabsheets on one main form. Each form had lots of components and procedures.

If I put all the components onto tabsheets on the main form, do all the procedures now have to be in the main.pas? Can I use separate .pas files as before and include them somehow? Can I use the pas and .dfm units I already have?

Basically, I want to keep the code separate for each tabsheet, and I don't want to have to rewrite all the forms.
 
Here's how to dynamically place a Delphi Form into a TabSheet of a TPageControl - while still being able to use a Form as a stand-alone window.

Note: We are placing an instance of a "TMyForm" form in a new TabSheet for an existing TPageControl component named "PageControl1".

~~~~~~~~~~~~~~~~~~~~~~~~~
var
aForm : TMyForm;
tabSheet : TTabSheet;
begin
//Create a new tab sheet
tabSheet := TTabSheet.Create(PageControl1) ;
tabSheet.PageControl := PageControl1;

//create a form
aForm := TMyForm.Create(tabSheet) ;
aForm.Parent := tabSheet;
aForm.Align := alClient;
aForm.BorderStyle := bsNone;
aForm.Visible := true;
tabSheet.Caption := aForm.Caption;

//activate the sheet
PageControl1.ActiveSheet := tabSheet;
end;



Aaron Taylor
John Mutch Electronics
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top