CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: MDI Application

  1. #1
    Join Date
    Jul 1999
    Posts
    84

    MDI Application

    I have an MDI application in which there are one Mainform(call MainScreen) and two child forms (Call Form1 and Form2). The Window state of the Main form is set as Maximized in the design form. I have a menu (call file) in the MainForm by clicking on which two child forms are dispalyed.


    private Sub file_Click()
    Form1.Show
    Form2.Show
    End Sub




    I have written the follwing code in the Resize event of the child forms.


    private Sub Form_Resize()
    Dim iWidth as Integer, iHeight as Integer
    Dim iTop as Integer, iLeft as Integer
    Dim bMax as Boolean
    bMax = false
    If me.WindowState = vbMaximized And Not bMax then
    me.Hide
    bMax = true
    me.WindowState = vbNormal
    me.Width = MainScreen.Width / 1.4
    me.Height = 2.4 / 3 * MainScreen.Height
    me.Top = MainScreen.Top + MainScreen.Height / 50
    me.Left = MainScreen.Left + MainScreen.Width / 3.8
    me.Show
    ElseIf bMax = true And me.WindowState = vbMaximized then
    me.Hide
    me.WindowState = vbNormal
    me.Width = iWidth
    me.Height = iHeight
    me.Top = iTop
    me.Left = iLeft
    bMax = false
    me.Show
    ElseIf Not bMax then
    iWidth = me.Width
    iHeight = me.Height
    iTop = me.Top
    iLeft = me.Left
    End If

    End Sub




    Now when I run the application and click on the file menu then both the forms Form1 and Form2 are shown. Now If I double click on the titlebar of the one Form say Form1 then the Form_Resize() event of the secondform, ie Form2, is getting fired.

    In the above Form_Resize(), what I am trying to do is to bring the Form size to required size when double clicked on the form. I am hiding the form to avoid the flickering effect.

    Can anybody please tell me why is it happening and the solution to avoid this.



    Thanks
    Harini

  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: MDI Application

    Well, that's a problem with MDI, in most cases, it's all or nothing, that is, all maximized, or none maximized. This is an automatic behaviour that I don't think can be disabled (it's like the menu's moving form child to parent). Although I believe that it miht be possible with subclassing, but I don't have a clue how.

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: MDI Application

    make this modify: comment the line with
    'Me.Hide
    in resize event of your forms, and look what appens...
    (Sorry Cakkie: I think I catch you another time...!!)

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: MDI Application

    Reason is: odd behaviour when hided...You will have to take the flickering effect

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured