Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Resize and cascade

Posted on 1998-08-10
7
Medium Priority
?
305 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
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.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

609 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