"Steve" <an*******@discussions.microsoft.com> schrieb
The dialog is displayed incorrectly from a subroutine
that is envoked as the result of a barcode scanner
sending data to a serial port, which I guess could be on
a different thread to the main program?
Is there a way of getting the main form thread to display
this dialog window instead?
"I guess could be on a different thread".. I'd say you should confirm this
first. I assume this is the only reason why the app behaves like it does, so
you should marshal showing the modal Form to the main UI thread in order to
make it modal for the whole app (assuming there should only be one UI
thread). You can show it in the main thread by calling a procedure using the
Invoke or BeginInvoke methods of any control (inclduing Form) created in the
main thread. You can pass a Delegate pointing to the procedure to be called
to the Invoke/BeginInvoke methods. The procedure will be executed in the
other thread. The MethodInvoker Delegate might be useful in this context.
There you can modally show the Form. But first, as I said, you should make
sure that it is currently really shown in a new thread, e.g. by having a
look at the thread windows.
--
Armin
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html