Messagebox location

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Doug Robertson

    #1

    Messagebox location

    I hope this is one of those simple questions that for some reason or another,
    I'm just missing the obvious.

    Using VB.NET 2003

    I want my messagebox to display centered on the parrent form instead of the
    desktop. The docs say to use

    messagebox.show (owner as IWin32Window, ...

    How do I obtain "owner" and successfully pass it as a parameter. Everything
    I've tried either generates and error or simply results in the messagebox
    centered on the desktop like always.

    Thanks for any help

  • Scott M.

    #2
    Re: Messagebox location

    Owner is the name of the form instance that the messagebox is supposed to
    center itself on.

    "Doug Robertson" <DougRobertson@ discussions.mic rosoft.com> wrote in message
    news:71986C45-08A1-483E-A664-814B18638AB4@mi crosoft.com...[color=blue]
    >I hope this is one of those simple questions that for some reason or
    >another,
    > I'm just missing the obvious.
    >
    > Using VB.NET 2003
    >
    > I want my messagebox to display centered on the parrent form instead of
    > the
    > desktop. The docs say to use
    >
    > messagebox.show (owner as IWin32Window, ...
    >
    > How do I obtain "owner" and successfully pass it as a parameter.
    > Everything
    > I've tried either generates and error or simply results in the messagebox
    > centered on the desktop like always.
    >
    > Thanks for any help
    >[/color]


    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Messagebox location

      "Scott M." <s-mar@nospam.nosp am> schrieb:[color=blue]
      > Owner is the name of the form instance that the messagebox is supposed to
      > center itself on.[/color]

      That's not true. Messageboxes are centered on the screen, not over the form
      by default, even if an owner window is set.

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: Messagebox location

        "Doug Robertson" <DougRobertson@ discussions.mic rosoft.com> schrieb:[color=blue]
        > I want my messagebox to display centered on the parrent form instead of
        > the
        > desktop. The docs say to use
        >
        > messagebox.show (owner as IWin32Window, ...
        >
        > How do I obtain "owner" and successfully pass it as a parameter.
        > Everything
        > I've tried either generates and error or simply results in the messagebox
        > centered on the desktop like always.[/color]

        You will have to use a Win32 dialog hook to catch creation of the message
        box and then set its position accordingly. Sample in VB6:

        DialogPosition
        <URL:http://dotnet.mvps.org/vb/samples/misc/DialogPosition. zip>

        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

        Comment

        • Scott M.

          #5
          Re: Messagebox location

          While it may be true that message boxes center on the screen, it is also
          true that "owner" is "The System.Windows. Forms.IWin32Win dow the message box
          will display in front of." This comes directly from the VS.NET help.

          ms-help://MS.VSCC.2003/MS.MSDNQTR.2004 APR.1033/cpref/html/frlrfsystemwind owsformsmessage boxclassshowtop ic12.htm




          "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
          news:eb5ZV9Y0EH A.1192@tk2msftn gp13.phx.gbl...[color=blue]
          > "Scott M." <s-mar@nospam.nosp am> schrieb:[color=green]
          >> Owner is the name of the form instance that the messagebox is supposed to
          >> center itself on.[/color]
          >
          > That's not true. Messageboxes are centered on the screen, not over the
          > form by default, even if an owner window is set.
          >
          > --
          > M S Herfried K. Wagner
          > M V P <URL:http://dotnet.mvps.org/>
          > V B <URL:http://dotnet.mvps.org/dotnet/faqs/>[/color]


          Comment

          Working...