Click to See Complete Forum and Search --> : MDI Application


Harini
July 18th, 2001, 01:37 PM
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

Cakkie
July 19th, 2001, 01:13 AM
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
slisse@planetinternet.be

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

Cimperiali
July 19th, 2001, 07:37 AM
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.

Cimperiali
July 19th, 2001, 08:12 AM
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.