I'm I missing something? First you said that you want to show a message box
from within non-form class. I took it you don't have a form (e.g. console
application) and you want to show a message box from there. Now you are
talking about centering the box within your application, which means you do
have a form.
MessageBox is not a form, it uses MessageBox API to show the UI. It uses
also GetActiveWindow API to get the reference to the window that is going to
be used as owner, therefore it doesn't care where you show the message box
or how you create the application windows.
However message boxes are modal, which means one cannot switch to the main
UI until dismiss the message box. In order to work this way the message box
needs to be shown from the same thread that has created the main application
UI.
Regrading centering the message box I don't think you have options there.
Message boxes are always centered against the the desktop.
--
Stoitcho Goutsev (100) [C# MVP]
HomerW said:
I will have a problem to center it to the application window.