|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Invoke on Dialog not yet shownI want to call Invoke() on a dialog that has not yet been made visible with "Show()". When I make the Invoke() call, I get an exception like: System.InvalidOperationException: Cannot call Invoke or BeginInvoke on a control until the window handle has been created. at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous) at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args) at NRI.Scan.DoqRequest.getImage() in c:\acbell\si\NriScan\DoqRequest.cs:line 147 How can I give the dialog a handle without making it visible? I tried calling CreateControl() on the dialog to no avail. If the dialog is made visible, everything works fine, but of course, this isn't what I want :) Thanks for any help, -- Andrew Bell andrew.bell***@gmail.com Hi Andrew,
Mark the dialog's Visible property as false. Then create it, you would have a handle to the dialog that you could call invoke on it with the dialog showing. HTH, ~d <andrew.bell***@gmail.com> wrote in message Show quoteHide quote news:1111082219.173724.233440@z14g2000cwz.googlegroups.com... > Hi, > > I want to call Invoke() on a dialog that has not yet been made visible > with "Show()". When I make the Invoke() call, I get an exception like: > > System.InvalidOperationException: Cannot call Invoke or BeginInvoke on > a control until the window handle has been created. > > at System.Windows.Forms.Control.MarshaledInvoke(Control caller, > Delegate method, Object[] args, Boolean synchronous) > at System.Windows.Forms.Control.Invoke(Delegate method, > Object[] args) > at NRI.Scan.DoqRequest.getImage() > in c:\acbell\si\NriScan\DoqRequest.cs:line 147 > > How can I give the dialog a handle without making it visible? I tried > calling CreateControl() on the dialog to no avail. If the dialog is > made visible, everything works fine, but of course, this isn't what I > want :) > > Thanks for any help, > > -- Andrew Bell > andrew.bell***@gmail.com > This doesn't work. As the documentation says, calling "Show" will make
the dialog visible, which isn't what is wanted. For anyone else having the same problem, I found the solution in another newsgroup. Accessing the "Handle" property seems to cause the handle to get created: form.Handle.toInt32(); does the trick.
Other interesting topics
Why exception when going through the DataSet?
Convetting string/text to datetime How to show a datetime field in a TextBox Question about Sockets Problem with deriving System.EventArgs setting security from code Programmatically retrieving photos How to call ASP page from C# application? ComboBox find item based on value String vs string |
|||||||||||||||||||||||