Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I load a MDI child form without displaying it?

Status
Not open for further replies.

Thrakazog

Programmer
Dec 10, 2001
48
US
I've got this code in my MDI form:

Dim strHandle As String
Dim frmTest As New Form
frmTest.MdiParent = Me
frmTest.Visible = False
strHandle = frmTest.Handle.ToString

The problem is that frmTest displays itself when I read the Handle information. The form isn't supposed to be visible. I need it fully loaded so I can access properties/methods. But I don't want it displayed until the user needs it.

How can I load a form and access it without it displaying??

Thanks.
 
Thanks Rick, but that doesn't do it either. I think the biggest problem is that I need to ask the form for it's handle. This seems to force it to display itself.

I'm starting to suspect that it can't get a windows handle without creating the window. DOH!
 
Cheat .....

Code:
Public Class ChildForm2
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

  Public Sub New([b]ByRef[/b] MyHandle As IntPtr)
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    MyHandle = Me.Handle

    'Add any initialization after the InitializeComponent() call

  End Sub

Code:
    Dim cf2Handle As IntPtr
    cf2 = New ChildForm2(cf2Handle)
    cf2.MdiParent = Me
    MessageBox.Show(cf2Handle.ToString)
    'cf2.Show()


Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top