Solved

Resize and cascade

Posted on 1998-08-10
7
287 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

730 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