Valleriani
asked on
Visual Basic 2010 - How to generate Window Handle without calling 'form.show' first?
I'm trying to load a form after I receive data from my client. I pretty much want to load the form AFTER the data has been received and processed.
I have:
I click a button on my mainform to load up a "Creation" form.. I have to use a Invoke to load up the Creation form when getting the data, otherwise the Creation form locks up/acts funny.
So data will be send like this: CreationX.Invoke(dlg, param) to the right form in the module file. (Dim param(0) As Object, dlg As New delegatedReceiveData(Addre ssOf processData))
If I do this:
CreationX = New Creation
CreationX.Show()
Before sending the data, it works fine and dandy, but If i do this without the .Show, it ends up crashing stating 'CreationX' was pretty much not defined. Issue is, I don't want to .show then .hide just to get it to initialize properly. ({"Invoke or BeginInvoke cannot be called on a control until the window handle has been created."})
So the question is how to generate the window handle WITHOUT calling .Show so I can plug everything in before I call .Show!
Thanks!
I have:
I click a button on my mainform to load up a "Creation" form.. I have to use a Invoke to load up the Creation form when getting the data, otherwise the Creation form locks up/acts funny.
So data will be send like this: CreationX.Invoke(dlg, param) to the right form in the module file. (Dim param(0) As Object, dlg As New delegatedReceiveData(Addre
If I do this:
CreationX = New Creation
CreationX.Show()
Before sending the data, it works fine and dandy, but If i do this without the .Show, it ends up crashing stating 'CreationX' was pretty much not defined. Issue is, I don't want to .show then .hide just to get it to initialize properly. ({"Invoke or BeginInvoke cannot be called on a control until the window handle has been created."})
So the question is how to generate the window handle WITHOUT calling .Show so I can plug everything in before I call .Show!
Thanks!
ASKER
Load(CreationX) doesn't seem to be happy in VB2010. Including Load requiring two variables and possibly 'Raiseevent' before it, but I'm not really sure, coulnd't get it going.
Load(sender as object, e as system.eventargs)
Load(sender as object, e as system.eventargs)
Set Opacity() to 0 (zero) and ShowInTaskBar() to False. This will allow to you to Show() it without it physically being visible.
*To make it visible at run-time:
f2.Opacity = 1
*To make it visible at run-time:
f2.Opacity = 1
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim f2 As New Form2
f2.Show()
' ... proceed to use "f2" ...
End Sub
End Class
Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Opacity = 0
Me.ShowInTaskbar = False
End Sub
Private Sub Form2_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
MessageBox.Show(Me.Handle.ToString("X"))
End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you. This actually solved it best due to I already was invoking, just didnt call the handle first. Thanks!
Will allocate the object and call Form_Load but not form_init