?
Solved

Resize and cascade

Posted on 1998-08-10
7
Medium Priority
?
301 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 210 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

764 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