Results 1 to 6 of 6

Thread: messagebox position?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2015
    Location
    Connecticut, USA
    Posts
    147

    messagebox position?

    Can a messagebox be shown centered in the parent window instead of centered to the screen?

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: messagebox position?

    As far as I know you can't specify a message box's position.

  3. #3
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,715

    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
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,990

    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

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Apr 2015
    Location
    Connecticut, USA
    Posts
    147

    Re: messagebox position?

    Quote Originally Posted by Shaggy Hiker View Post
    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.

  6. #6
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: messagebox position?

    Quote Originally Posted by Maylar View Post
    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,....
    Name:  WindowsAppearance.png
Views: 8306
Size:  34.9 KB

    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
  •  



Click Here to Expand Forum to Full Width