Re: My.Application.OpenForms



Yes,

Thank you Stephany.

That does work now.

I moved the .Show() to end of any further manipulations and the resultant
DISPLAY was perfect

Thanks very much again.

Garry


"Stephany Young" <noone@localhost> wrote in message
news:%23fGkpgbIHHA.1468@xxxxxxxxxxxxxxxxxxxxxxx
Ok, so I made a little mistake. It does work if the StartPosition property
of Form2 is set to
Manual or CenterScreen. It doesn't work if it is set to anything else. I
thought that the fact that it didn't work for one setting might have led
you to investigate the others.

If you start manipulating the position of MDI Child forms after they have
been shown then you WILL get flicker as the repaints occur.


"Garry" <garrygrolman@xxxxxxxxx> wrote in message
news:uCifEAaIHHA.1248@xxxxxxxxxxxxxxxxxxxxxxx
OK.

I tried the solution Stephany but the results were not quite as I
expected.

The code was revised as

Shared Sub A_ResizeToFit(ByVal frmMain As Form, ByVal _f As Form)
' parent the form the the MDI Container
_f.MdiParent = frmMain

' make the form fill the client area of the MDI Container
For Each _c As Control In frmMain.Controls
If _c.GetType Is GetType(MdiClient) Then
_f.Bounds = CType(_c, MdiClient).ClientRectangle
Exit For
End If
Next
_f.Show()
End Sub

Which I think you will agree is correct with small name changes. The
result was a cascaded arrangement whereby the first mdi child generated
was at a small displacement and each subsequent MDI child generated at a
furthur displacement.

I solved the problem with the following code which you may or may not
make use of. It is a function which can be placed in a class and has a
displacement from the left to allow a Tree navigator as a separate MDI
child to be displayed alongside the MDI child.

Shared Sub FitChildToMDI(ByVal frmMDI As Form, ByRef frmChild As Form,
ByVal lngTreeWidth As Long)

Dim lngTop As Long
Dim lngLeft As Long
Dim lngWidth As Long
Dim lngHeight As Long
frmChild.Dock = DockStyle.Fill

frmChild.Show() 'Do a 'show' to capture the true size and position of
the MDI child before removing the DockStyle.Fill
lngTop = frmChild.Top
lngLeft = frmChild.Left
lngWidth = frmChild.Width
lngHeight = frmChild.Height
frmChild.Dock = DockStyle.None

'Now manipulate the form to size and position - it can be resized by
the user anytime as it is now DockStyle.None
frmChild.Top = lngTop
frmChild.Left = lngLeft + lngTreeWidth
frmChild.Width = lngWidth - lngTreeWidth
frmChild.Height = lngHeight

End Sub

BUT
It causes a flicker which is not to my liking.
I was all so simple in VB6 and I find this code, to say the least -
gross.

Your's was much more elegant but did not give me the required results
that I needed. It was however a valid attempt and thank you for that. I
have learned something.

Thanks again

Garry


.

"Stephany Young" <noone@localhost> wrote in message
news:e4vagkVIHHA.2632@xxxxxxxxxxxxxxxxxxxxxxx
I hit hit F1, switched to the index tab, typed in 'mdiclient', selected
'about MdiClient class', noticed that it it derived from
System.Windows.Forms.Control, scrolled down a bit and read the remarks,
tried a stock standard 'controls loop' to check that it was actually
present, then had a look at the members to find a suitable property or
method.

BTW. It doesn't work if the StartPosition property of Form2 is set to
WindowsDefaultsBounds.


"Garry" <garrygrolman@xxxxxxxxx> wrote in message
news:Omw6dbTIHHA.4112@xxxxxxxxxxxxxxxxxxxxxxx
Thank you Stephany,

Will try and re-post.

Assuming that it werks, where did U get it or woz it simply
INTUITIVE???????

Garry




"Stephany Young" <noone@localhost> wrote in message
news:ecH3pIPIHHA.3668@xxxxxxxxxxxxxxxxxxxxxxx
Leesten veeeery carefully. I shall say theees only vonce!

Dim _f As New Form2

' parent the form the the MDI Container
_f.MdiParent = Me

' make the form fill the client area of the MDI Container
For Each _c As Control In Controls
If _c.GetType Is GetType(MdiClient) Then
_f.Bounds = CType(_c, MdiClient).ClientRectangle
Exit For
End If
Next

_f.Show()

Et voila!!!!!!!!!!


"Garry" <garrygrolman@xxxxxxxxx> wrote in message
news:uCoTCYEIHHA.4804@xxxxxxxxxxxxxxxxxxxxxxx
Why do you hesitate to have a form as your startup?
Conservatism - an abominable affliction in a computer programmer.

The problem is not the Startup but I will remember your comment if I
do change back to frmMain as the start form.

Have you solved the problem of sizing a child form to fit the MDI
client rectangle BUT, the user must be able to move the form within
the parent form.. My solution is not elegant and I wonder how other
people solved it. Perhaps other programmers do not need to. I do not
want the child maximised, thats too easy, I want the child to
completely fill the available area and yet be 'moveable'.

I saw a solution to a forms collection in code with the Load event
being used in each child form to add it to a User Defined forms
collection. I have to consider this carefully. It was written for
VS2003 and the article specifically states that the 'openforms' is
available in 2005.

I say it again - things were so simple in VB6.

If only someone had uddated the VB6 GUI and come out with a non
Microsoft VB7 with the improved intellisense on vb2005.

A DOTNET framework for Linux or Mackintosh has not materalised so
that one of the much taunted features at the release of the .NET
languages back in 2002 has not been realised. Garbage Collection is
simply not mentioned any more. I am however, enjoying ADO.NET with
SQLCE which has replaced my original Access database. Very fast.

Anyway, thanks for your answers.

Garry



"RobinS" <RobinS@xxxxxxxxxxxxxxx> wrote in message
news:F8qdnYO0iaq3pB_YnZ2dnUVZ_hy3nZ2d@xxxxxxxxxxxxxx
Unfortunately, I figured out MDI stuff by trial & error, and
the ones I've written are fairly simple. I do have MacDonald's
Windows Forms book; it has some basic info on MDI, but not tons.
You could always search Google.

I have the startup form for my project set to the parent form.
Why do you hesitate to have a form as your startup?

Robin S.
-------------------------------
"Garry" <garrygrolman@xxxxxxxxx> wrote in message
news:%2372JBgAIHHA.2632@xxxxxxxxxxxxxxxxxxxxxxx
Ah Robin,

I just noticed that in the project Properties, Application tab, the
'enable application framework' checkbox is unchecked.

I did this to enable me to build an MDI application and use sub
Main() as the starting point for the code.

There is very little clear info on building MDI applications as
Microsoft presumably is not encouraging the MDI framework. (no
internal support for INI files either in vb2005). Just try to
resize an MDI child to fit the Client Rectangle in the parent form
exactly. It was all so simple in VB6

However, I wonder if you could 'point' me to relevant and truly
constructive info on MDI applications in VB2005 'cos I MAY have to
redefine my application.

Is there anything else that I may be missing from My.Application if
I leave this checkbox unchecked????? I assume that this checkbox is
the source of my present troubles.

I am re-writing completely from VB6, NOT converting and do not feel
comfortable with the frmMain as the StartUp object.

One of the disadvantages of unchecking the checkbox is that when
using Cntrl-Break to debug, the Sub Main() is always shown with the
green line background on Application.Run(frmMain)..

Any clear suggestions would be much appreciated.

Garry


"RobinS" <RobinS@xxxxxxxxxxxxxxx> wrote in message
news:P4CdnVmUhu7b4hzYnZ2dnUVZ_rSjnZ2d@xxxxxxxxxxxxxx
I hate to ask the obvious, but is it a Windows Forms application
that you're trying to use it in?

Robin S.
----------------------------
"Garry" <garrygrolman@xxxxxxxxx> wrote in message
news:uHpO9r5HHHA.2236@xxxxxxxxxxxxxxxxxxxxxxx
Why is it that my installation od vs2005 will not accept
My.Application.OpenForms saying that it is not part of
My.Application???

Dim frm As Form
For Each frm In My.Application.OpenForms

Next frm


Garry






















.



Relevant Pages

  • Re: My.Application.OpenForms
    ... If you start manipulating the position of MDI Child forms after they have ... Dim lngLeft As Long ... It doesn't work if the StartPosition property of Form2 is set to ...
    (microsoft.public.dotnet.languages.vb)
  • Re: My.Application.OpenForms
    ... It was much simpler in VB6 ... If you start manipulating the position of MDI Child forms after they have ... Dim lngLeft As Long ...
    (microsoft.public.dotnet.languages.vb)
  • Re: My.Application.OpenForms
    ... Shared Sub A_ResizeToFit(ByVal frmMain As Form, ... ' make the form fill the client area of the MDI Container ... small displacement and each subsequent MDI child generated at a furthur ... Shared Sub FitChildToMDI(ByVal frmMDI As Form, ByRef frmChild As Form, ByVal ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Multiple MDI Child Icons and Control Boxes Why??
    ... If your start form is not maximized, but you bring up another MDI child that ... MDI children are either all ... > and put the Start form back to how it was (with control box and max button ... >> icon is usually the icon from the last form opened not the start form's ...
    (microsoft.public.dotnet.languages.vb)
  • Help needed with Asynchronous threading
    ... I have the below code in an MDI childform which saves a dataset to a temp ... Dim xmlDOMSchema As New XmlDocument ... Dim strCSV As String ... With ProgressForm ...
    (microsoft.public.dotnet.framework.windowsforms)

Loading