Moving Tab Control With SubForms Within?

  • Thread starter Thread starter (PeteCresswell)
  • Start date Start date
P

(PeteCresswell)

I've got a screen with a treeview in the top half and a tab control containing
about a dozen subforms in the bottom half.

When the user resizes the screen, I want to maintain the size of the tab
control, but move it downwards/upwards and adjust the height of the treeview to
fill up the remaining space.

Needless-to-say, it's not going that well.

Question: Are there special considerations when moving things around within a
Tab control and also moving the Tab control itself?

Is there a chicken-and-egg problem here? i.e. As the Tab control is moved, do
the yet-unmoved subforms within it constrain it's motion? Or vice-versa?
 
This is tough to do right. Here are some hints:

Use the OnResize event.

Use the Left, Top, Width, and Height properties of your controls and
modify them as a percentage of Me.WindowHeight and Me.WindowWidth...
multiplied by a constant.

I tested it out making a blank form with a text box on it:

Private Sub Form_Resize()
Text0.Top = Me.WindowHeight * 0.25 / 2
Text0.Height = Me.WindowHeight * 0.5 / 2
End Sub

The text box follows the form size until you make it too big. You'll
have to add your own 'maximum' so it doesn't crash. Why I must divide
by two is beyond me, it just works better. Obviously the units are
missmatched and dividing by two helps.


Good Luck,
~J
 
Per (e-mail address removed):
Use the Left, Top, Width, and Height properties of your controls and
modify them as a percentage of Me.WindowHeight and Me.WindowWidth...
multiplied by a constant.

I tested it out making a blank form with a text box on it:

Private Sub Form_Resize()
Text0.Top = Me.WindowHeight * 0.25 / 2
Text0.Height = Me.WindowHeight * 0.5 / 2
End Sub

The text box follows the form size until you make it too big. You'll
have to add your own 'maximum' so it doesn't crash. Why I must divide
by two is beyond me, it just works better. Obviously the units are
missmatched and dividing by two helps.

That works A-OK.

My problem is making it happen when the objects (subforms, in my case) are
within pages on a Tab control
 
I think I get it now:

Your problem is that the location of an object within a tab control is
still referenced from the top left of the entire form. You can try to
move the tab control encompassing them, but the controls inside want to
stay where they are.

Here's my suggestion:
On the resize, do the following
1) Increase the height of the tab control to the max the form will
carry (this should be a dynamic expression)
2) Move the controls inside
3) Change the height and top of the tab control to what they should be,
at the same time, using the WITH command

If the WITH command fails, build yourself a loop that inches the tab
control lower... expand tab control, increment 'sub' controls down,
lower tab control, unexpand tab control... repeating until you reach
desired location.

Hope that helps,
~J
 
Per (e-mail address removed):
Here's my suggestion:
On the resize, do the following
1) Increase the height of the tab control to the max the form will
carry (this should be a dynamic expression)
2) Move the controls inside
3) Change the height and top of the tab control to what they should be,
at the same time, using the WITH command

If the WITH command fails, build yourself a loop that inches the tab
control lower... expand tab control, increment 'sub' controls down,
lower tab control, unexpand tab control... repeating until you reach
desired location.

Hope that helps,

I'm still lost.

If anybody wants a more concrete statement of the problem, I posted
as sample db at http://tinyurl.com/oznty

It's about 112k to download.

MS Access 2003.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top