Showing posts with label StartPosition. Show all posts
Showing posts with label StartPosition. Show all posts

Friday, May 16, 2008

StartupPosition for MessageBox

Sometimes it seems that .NET has some obvious shortcomings. For example, all I want to do is have a MessageBox center in my application instead of the screen. This task shouldn't be that difficult; however, there is no way (that I have found) to set the StartPosition property for the MessageBox dialog. While there may be a functional and elegant solution to this problem (please post as a comment if you have one), the only solution I have found on the internet is to implement your own MessageBox class, and code it to do what you want. This isn't hard, but it doesn't seem like a lot of work for something so simple. Also, the Messagebox probably does more than you might first think. It does a lot of autosizing to hold whatever text you provide it.

Here is one implementation of a custom MessageBox I have found:

http://www.codeproject.com/KB/dialog/MessageBoxEx.aspx?fid=155440&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=76&select=1069708

I am sure there are more such implementations. Please post comments if you know of any.