Resize 2 Forms at Once Like HTML Frames

P

pcross29

I'm envisioning an application with 2 forms filling up the screen, one
on top of the other. The user could drag in the middle to resize both
simultaneously just as you would a website with 2 frames. How can I do
this?

-- Thanks for helping. Paul C
 
D

Douglas J. Steele

Put code in the Resize events of both forms, referring to each other. If the
Width of FormA decreases by a certain amount, increase the Width of FormB
and so on.
 
M

Marshall Barton

I'm envisioning an application with 2 forms filling up the screen, one
on top of the other. The user could drag in the middle to resize both
simultaneously just as you would a website with 2 frames. How can I do
this?


It's not 100% foolproof, but the Resize event gives you a
hook to work with. In the code below Form8a is on the left
and Form8b is on the right.

code in the left form:
----------------------------------------
Private Sub Form_Resize()
Dim xa As Long, xb As Long
Dim wa As Long, wb As Long

With Forms!Form8b
wa = Me.InsideWidth + 165
wb = Me.Width + .Width - wa
xa = Me.WindowLeft
xb = xa + wa

.Move xb
.InsideWidth = wb
End With

End Sub

code in the right form:
----------------------------------------
Private Sub Form_Resize()
Dim wb As Long

With Forms!Form8a
wb = Me.InsideWidth + 165
.InsideWidth = Me.Width + .Width - wb
End With

End Sub

The 165 is a fudge factor guess at the difference between
the form's InsideWidth and its "outside" width. This can
vary with your use of record selectors, scroll bars,
BorderStyle and ???

There seems to be a minimum width for a form (based on the
stuff in the form's title bar?) where things start to break
down.

Note that this approach will not work with subforms.
 

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

Top