CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 1999
    Posts
    84

    Resizing Child forms to different sizes in MDI Application-Please help

    Hello,

    I have an MDI application in which I have one Mainscreen and two child forms. when I double click on the title bar of one of the child forms then the Form_Resize() event of the second form is getting called. Can any body tell me why it is happening and how to avoid it. The code that I wrote in the Form_Resize() event of the both the forms (Form1 & Form2) is as follows.


    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



    MainScreen is the name of the MDI parent form.

    I have written the above code in the Resize event to bring the form to the size that I want when double clicked on the form titlebar. I want to hide/show the form to avoid the flickering effect on the screen.


    Thanks
    Harini

  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Resizing Child forms to different sizes in MDI Application-Please help

    I tried a simple experiment, but couldn't simulate the behavior you report
    I put a MDI form, and two child forms Form1 and Form2

    In MDIForm1

    private Sub MDIForm_Load()
    Dim aForm as Form1, bForm as Form1, cForm as Form2
    set aForm = new Form1
    aForm.Tag = "First A"
    aForm.Show
    set bForm = new Form1
    bForm.Tag = "First B"
    bForm.Show
    set cForm = new Form2
    cForm.Tag = "Second"
    cForm.Show
    End Sub




    In Form1,

    private Sub Form_Resize()
    MsgBox "Resized " & me.Tag
    End Sub




    It always resizes only the form whose title bar I double clicked.


  3. #3
    Join Date
    Jul 1999
    Posts
    84

    Re: Resizing Child forms to different sizes in MDI Application-Please help

    Hello Shree,

    Thank you for your prompt response. I have also made a sample MDI application, with two child forms, which behaves in the way I have mentioned. When one form's title bar is dbl-clicked the other ones resize event is called.

    Can you please let me know if there is any way in which I can send you the sample application. It would be great of help if I can send you the sample application.

    Thanks
    Harini

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