Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Displaying Two Children Forms In A MDI Form

Posted on 2002-04-28
10
Medium Priority
?
336 Views
Last Modified: 2010-05-02
Displaying Two Children Forms In A MDI Form

Hi,

I want to create a user interface in VB where in the left side of the application displays a
TreeView control displaying the heirarchy of other forms in the application.

I exercised this option with SDI forms but it considerably slows down the application as the
Treeview control has to be created on every form.

In MDI application I am not able to persist two forms at the same time. i.e. when an MDI
application is run, the first form that consists the Tree View control is loaded on the left side
of the Parent window and occupies 20% of the MDI Parent's space.
On click of a node on the Treeview I want to display a form in the remaining 80% right side of
the MDI form.

However it is not happening and the second form when displayed occupies the whole MDI area, thereby
shadowing the form contianing TreeView control.

I have tried the Left and Top properties while displaying the second form, but they are not
working.

Please suggest.

Thanks.
0
Comment
Question by:Sethi
10 Comments
 
LVL 5

Expert Comment

by:raizon
ID: 6976175
have you tried calling the form_resize event from the form_load event in the second child form.  And in the form_resize set the left and top
0
 
LVL 18

Author Comment

by:Sethi
ID: 6976320
It gives an error in For_Resize event.
'Form cant't be move or resized in Maximize and Minimize state'...I have ensured that the Windows state is vbNormal, but still the error persists.
0
 
LVL 2

Expert Comment

by:corvanderlinden
ID: 6976502
Is the BorderStyle of your form Sizeable ?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 18

Author Comment

by:Sethi
ID: 6976705
Yes, MDI doesn't accept any other border style.
0
 
LVL 10

Accepted Solution

by:
RichardCorrie earned 200 total points
ID: 6976716
In the MDI form put a Picture box (picParent) ensure the Align property = 3 - align Left.  

Put the Tree view control (treParent) into the picture Box

In the MDIForm_Resize event put:

if me.windowsate <> vbminimized then
  picParent.width = me.width *.2
  with treParent
      .left = 0
      .top = 0
      .width = picParent.width
     .height = picparent.height
  end with
end if

In the Form_Open event of the child windows put

me.windowsate = vbMaximized

When any child form opens it will occupy the remaining 80% of the MDI form.  

Richard
0
 
LVL 3

Expert Comment

by:n_narayanan
ID: 6976718
You can not use the form for displaying the Treeview.

Put a Picture box with align property set to left. Draw a Treeview control in that. Size the picture box to 20% of your mdi form.

Now all the other forms will occupy 80%of the remaining area.


Cheers

Narayanan.
0
 

Expert Comment

by:ajit77
ID: 6976745
Hi Sethi,

I've did this last year...i used MDI application..but instead of using a form to hold the tree control, i used a 'Splitter' control instead (Sheridan)..its much easier, all u have to do is drop the Splitter control on your MDI form, the form will automatically divide into 2, so then u can drop the tree control, it will fit nicely in the container (left side of the split)...furthermore u can resize the width of the tree control during runtime just like wondows file explorer....and ure child forms will be loaded to the right side of the splitter...

0
 
LVL 2

Expert Comment

by:corvanderlinden
ID: 6977049
Works fine for me.
Be sure to set Sub Main or MDIForm as startup form

VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form Form1
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   Begin MSComctlLib.TreeView tretREE
      Height          =   2655
      Left            =   240
      TabIndex        =   0
      Top             =   120
      Width           =   975
      _ExtentX        =   1720
      _ExtentY        =   4683
      _Version        =   393217
      Style           =   7
      Appearance      =   1
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

VERSION 5.00
Begin VB.Form Form2
   Caption         =   "Form2"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form2"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  'Windows Default
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit


VERSION 5.00
Begin VB.MDIForm MDIForm1
   BackColor       =   &H8000000C&
   Caption         =   "MDIForm1"
   ClientHeight    =   7320
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   10170
   LinkTopic       =   "MDIForm1"
   StartUpPosition =   3  'Windows Default
End
Attribute VB_Name = "MDIForm1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub MDIForm_Load()

Dim f As Form1
Dim f2 As Form2


    Set f = New Form1
    With f
        .Top = 0
        .Left = 0
        .Width = 500
        .Height = Me.ScaleHeight
        .Show
    End With
   
    Set f2 = New Form2
    With f2
        .Left = f.Width
        .Top = 0
        .Width = Me.ScaleWidth - f.Width
        .Height = Me.ScaleHeight
    End With
End Sub
0
 
LVL 18

Author Comment

by:Sethi
ID: 6977903
Ajit77, where can I get the Splitter control from ??
0
 
LVL 18

Author Comment

by:Sethi
ID: 7002980
Thanks. It works excellently.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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

963 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