Solved

Resize and cascade

Posted on 1998-08-10
7
294 Views
Last Modified: 2010-04-30
I created 2 type of mdichild form :
A form :  should always stay at the left side of the mdiform
B form :  stays beside A form.
That means,when A resize, B will resize too so that both can occupy and share the view space.
There are times where only A form appear.
Some time only B form appear and B form can be many (cascading)

This is exactly like the VB5 developing environment.

0
Comment
Question by:chualk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 14

Expert Comment

by:waty
ID: 1468393
you should set the position and size of each form in resize event of each form.

Define globally 2 variables :
  Global FormA    as Form
  Global FormB    as Form

in the Form_Load of each form do the following :
  Set FormX = new Form
  Set FormX = Me

in the Form_UnLoad of each form do the following :
  Set FormX = nothing

In the risize event, use the 2 variable to set the correct size and position

  FormB.Width = MDIMain.Width - FormA.Width
  FormB.Left = FormA.Left + Form1.Height

.

Put all the need code for you here


0
 
LVL 1

Author Comment

by:chualk
ID: 1468394
Waty :

Please note that there are some situation that only form A or FormB will load.
The resize_event will activate everytime a form is loaded.
So there will be a run time error because another form is not found.
0
 
LVL 14

Expert Comment

by:waty
ID: 1468395
you have to test if the form contains valid information :

if FormB is Nothing then
   ' *** FormB is not loaded
Else
   ' *** Do work on FormB
End If
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 1

Author Comment

by:chualk
ID: 1468396
It doesn;t work well
0
 
LVL 14

Expert Comment

by:waty
ID: 1468397
This is the best solution. I have used it in some projects.

Tell what's wrong
0
 
LVL 1

Author Comment

by:chualk
ID: 1468398
Waty:

Your way is not wrong but somehow there are some problems.These are the code i test. Point out if i misunderstood your code or really cannot overcome this.


Global form1 As Form
Global form2 As Form

'Code for form2

Private Sub Form_Load()

   Set formx = New form2
   Set formx = Me
End Sub

Private Sub Form_Resize()
 If Not form1 Is Nothing Then
    form2.Width = MDIForm1.Width - form1.Width
    form2.Left = form1.Left + form1.Width
 End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
      Set formx = Nothing
End Sub

About the same code pasted on the form1.

IF i unload form1 and resize, form2 reload.
 
0
 
LVL 14

Accepted Solution

by:
waty earned 70 total points
ID: 1468399
I have tested the following code and works well :
If you give me your e-mail, I can send you the test project.

Add into your MDI (create 2 menus)
Private Sub m1_Click()
frm1.Show
End Sub

Private Sub m2_Click()
frm2.Show
End Sub

Private Sub MDIForm_Load()

   Set form1 = Nothing
   Set form2 = Nothing

End Sub

***************************************************************

Add into form1 :
Private Sub Form_Load()
   Set form1 = Me
End Sub

Private Sub Form_Resize()
 If Not form2 Is Nothing Then
    Me.Width = MDIForm1.Width - form2.Width
    Me.Left = form2.Left + form2.Width
 End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
   Set form1 = Nothing
End Sub

***************************************************************

Add into form2:
Private Sub Form_Load()
   Set form2 = Me
End Sub

Private Sub Form_Resize()
 If Not form1 Is Nothing Then
    Me.Width = MDIForm1.Width - form1.Width
    Me.Left = form1.Left + form1.Width
 End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
   Set form2 = Nothing
End Sub

***************************************************************

Add in a bas file

Global form1 As Form
Global form2 As Form

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question