473,399 Members | 3,656 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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

Nov 21 '05 #1
4 9782
Owner is the name of the form instance that the messagebox is supposed to
center itself on.

"Doug Robertson" <Do***********@discussions.microsoft.com> wrote in message
news:71**********************************@microsof t.com...
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

Nov 21 '05 #2
"Scott M." <s-***@nospam.nospam> schrieb:
Owner is the name of the form instance that the messagebox is supposed to
center itself on.


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/>

Nov 21 '05 #3
"Doug Robertson" <Do***********@discussions.microsoft.com> schrieb:
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.


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/>

Nov 21 '05 #4
While it may be true that message boxes center on the screen, it is also
true that "owner" is "The System.Windows.Forms.IWin32Window the message box
will display in front of." This comes directly from the VS.NET help.

ms-help://MS.VSCC.2003/MS.MSDNQTR.2004APR.1033/cpref/html/frlrfsystemwindowsformsmessageboxclassshowtopic12. htm


"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eb**************@tk2msftngp13.phx.gbl...
"Scott M." <s-***@nospam.nospam> schrieb:
Owner is the name of the form instance that the messagebox is supposed to
center itself on.


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/>

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Gerry Viator | last post by:
Hi all, Whats going on. Testing messagebox, text isn't showing up. Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code "
11
by: Rich Tasker | last post by:
I have a strange situation. A simple call to MessageBox.Show("XXX", "YYY") does not display the message in the messagebox with a visible font. Based on the content of the messagebox, the box...
2
by: Dennis C. Drumm | last post by:
This is a restatement of an earlier post that evidently wasn't clear. I am building a custom MessageBox dialog that has, among other things, a few new button options (yes to all, no to all, etc.)...
0
by: zfeld | last post by:
Is there any way to specify where I want my MessageBox to show? It seems to always show up in the middle of the screen. Even when I use the MessageBox.Show Method (IWin32Window, String, String,...
1
by: M. Roming | last post by:
Hi together, I am trying to center a MessageBox based on the form wich is calling the Show method. This means: After calling the Show() method I don't want the dialog window in the center of...
1
by: Gidi | last post by:
Hi, I finished writing my program, and i want to create an "about" messagebox, the thing is that i'm not sure that i should use the messagebox tool. what is the right tool to make an about...
10
by: Ed Bitzer | last post by:
One option of the messagebox object indicates it can be placed over a selected window rather than just appearing centered on the desktop. The function is "Overloads Public Shared Function...
5
by: jmelkerson | last post by:
In VB.Net 2005, is it possible to make MessageBoxes pop up somewhere other than centered on the Desktop? I develop on/for dual monitor systems and would like my MessageBoxes to not be split...
4
by: kelvin.koogan | last post by:
I am having difficulty persuading MessageBoxes to appear over my application (using C++/CLI in VS2005). I would expect MessageBox::Show(this, "Some message"); to cause the message box to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.