I am trying to get center of parent form, not center of screen behavior. Passing in the parent form seems to only control the ownership of the window. These classes are sealed, so I do not see how I can do any WinProc tricks. Rewriting the classes is not an appealing option. Any other ideas?
There are many built-in dialog boxes to be used in Windows forms for various tasks like opening and saving files, printing a page, providing choices for colors, fonts, page setup, etc., to the user of an application. These built-in dialog boxes reduce the developer's time and workload.
Property Valuetrue if the dialog box adds an extension to a file name if the user omits the extension; otherwise, false . The default value is true .
The Open dialog box lets the user specify the drive, directory, and the name of a file or set of files to open. You create and display an Open dialog box by initializing an OPENFILENAME structure and passing the structure to the GetOpenFileName function.
As HTH explained above, there are ugly ways to do it. Here is a simple class that will wrap the dialog box and center it in the parent application/Form.
It takes the ugly ways and wraps them to something slightly more simple.
While I haven't implemented this or really delved into the source, it's a good place to start. CodeProject CenterDialog
Hope this helps.
Without digging into some ugly P/invoke code to find and move the window after it is displayed, this simply impossible. If you pursue this, the message box will "jump" to the new position, which is generally worse than not having it centered. If the position is truly that important, you are much better off creating your own message box, or adopting one from CodeProject.
HTH
After some digging I found http://support.microsoft.com/kb/180936. This works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With