-
Oct 26th, 2016, 09:32 AM
#1
Thread Starter
Addicted Member
messagebox position?
Can a messagebox be shown centered in the parent window instead of centered to the screen?
-
Oct 26th, 2016, 10:03 AM
#2
Re: messagebox position?
As far as I know you can't specify a message box's position.
-
Oct 26th, 2016, 10:05 AM
#3
Re: messagebox position?
You can, but it gets a little tricky. From everything that I've read, you'll need to use user32 APIs.
In fact, here is a great example: http://stackoverflow.com/a/15905063
-
Oct 26th, 2016, 10:07 AM
#4
Re: messagebox position?
There's no reason to work very hard for this. A messagebox is nothing more than a modal form showing a label and a couple buttons. If the default messagebox function doesn't suit your needs, making a form that looks and feels like a messagebox, yet behaves the way you want, would take only a few minutes.
Don't waste time trying to modify the existing functionality. Instead, make new functionality.
My usual boring signature: Nothing
-
Oct 26th, 2016, 01:01 PM
#5
Thread Starter
Addicted Member
Re: messagebox position?
Originally Posted by Shaggy Hiker
There's no reason to work very hard for this. A messagebox is nothing more than a modal form showing a label and a couple buttons. If the default messagebox function doesn't suit your needs, making a form that looks and feels like a messagebox, yet behaves the way you want, would take only a few minutes.
Don't waste time trying to modify the existing functionality. Instead, make new functionality.
Roger that. That's what I did - took all of 5 minutes. But I figured that since the messagebox.show method has about 20 overloads maybe one of them had a not-so-obvious way to center it to the parent window. Guess not.
-
Oct 26th, 2016, 01:31 PM
#6
Re: messagebox position?
Originally Posted by Maylar
Roger that. That's what I did - took all of 5 minutes. But I figured that since the messagebox.show method has about 20 overloads maybe one of them had a not-so-obvious way to center it to the parent window. Guess not.
Just my 2 cents, but one problem making your own messagebox is it may not look like what the user is expecting, fonts too small, not bold, etc,,,. Windows has appearance settings the user can adjust, for example they may have messagebox setup to use a different font, size, color,....
I've made a few functions that move the messagebox to any point, center of a form, etc, based on this C# code here, and has worked great.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|