Click to See Complete Forum and Search --> : embedding VB Forms in a tab strip


nicholso
November 23rd, 1999, 02:27 PM
I have a bunch of individual dialog box forms (with associated action code) that I want to embed in a tabstrip, so that the user could access them all at once by selecting between them through tabs.

I have done this in VC++ by making the individual screens property pages and grouping them together that way, is there a similar way to do it in VB? Can I somehow invoke an instance of a particular form at runtime and stick it into one of the tab of a TabStrip control?

Ravi Kiran
November 24th, 1999, 12:48 AM
Hi,
It depends upon how much work you want to do!!
Assuming that your forms are developed in VB ( there is no hint in your question not to assume so!):
1. Remove the border styles for all the forms.
2. Add another form with a tabstrip with approp size. Ofcourse you can set the size at runtime also, depending on the form that is going to come!.
3. Associate each form to a tab strip button
4. When on a tab item click, follow the same procedure you use to show a frame which usually contains the controls ( in your case it is a seperate form thats all) ie:
Get the form to be displayed, its size , resize tab strip witdth & height if required and then position your form at clientleft/top

For all practical puposes you get the look and feel of a property pages, with one big exception: Because they are forms, the "parent" form (one with the tab strip) will lose focus when the "child" form (shown as property page) recieves the focus. Then its border gets dehilited indicating this. ( This doesnt happen in an ordinary property page set!)

This is with least work!, i would say
Other methods can be:
II. If you are ready for more work, create seperate frames for each of the form, and cut and paste the controls from the older forms. Their names remain same. But all the interation with the form needs to be carefulle replaced appriately.

Then when you do that for more than a couple of forms, i am sure you will have clasing of names .. and you will start having problems with accessing the wrong control.. etc

III : Still more work would be to move all the code to class modules, and define the controls "with Events" in them so that their implementation will be as seperate as possible. Move all the controls to one form with as distinct names, and write some code which will assign the controls to those classes correctly.

IV : Still more work would be to desing one user defined control for each of the form. So that form code will go into user control's class. etc
Then on your tab strip form just instanciate these controls and use it.
On second thoughts, it appears less work this way!:-). It gives more modularity than methods II and III.

RK

March 13th, 2000, 01:27 PM
I'm going through the same problem. I'd like to do your "simple" suggestion, but I don't really understand it.

- How do you do step 3? "Associate each form to a tab strip button." Do you do that in VB?

- If on step 4, all you are saying is overlay the child form over the parent frame by moving it in place, what do you do if the user wants to move the parent dialog?

I have not found an elegant solution to this problem. Maybe UserControls is the VB way to do this?