Loading an invisible form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How does one load a hidden form in VB.NET? There doesn't seem to be a design
time "visible" property any more?
 
I just tried that, and got an "Error creating window handle" exception on the
SendMessage call when running the following code:

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal
lParam As Integer) As Integer

Dim testform As New Form2
testform.Hide()
SendMessage(testform.Handle.ToInt32, &H8000, 0, 0)

Anybody know what's going on?
 
Dan,

You can change the API Declare to this:

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal
lParam As Integer) As Integer
 
Okay, I'm not sure what message it is you're sending, but if you use the
suggested SendMessage Declare, and this call, do you still experience the
problem?

SendMessage(testform.Handle, &H8000, 0, 0)
 
What are trying to do? Perhaps there is an alternate way to do what
you want to do?
 
Chris-- I am trying to subclass an invisible windows form by overriding its
WndProc method so that I can send custom messages to it from another process.

Carsten--I did exactly what you recommended with no luck

....Dan
 
How does one load a hidden form in VB.NET? There doesn't seem to be a design
time "visible" property any more?

At the top of the form's Load event, call Hide.
 
I figured out the problem. When I overrode the WndProc method in my form, I
forgot to pass along the messages via MyBase.WndProc(msg) before existing my
override.

Also, it seems that I can create the window without showing by simply
creating a new instance of the form without showing it.

Thanks very much for your help.

Dan
 
Dan said:
How does one load a hidden form in VB.NET?

You create an instance of the Form's class and use it like any other
class. It's only when you call the [Form] object's Show method
that anyone gets to see it.

HTH,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top