473,412 Members | 2,142 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,412 software developers and data experts.

Getting MessageBox to centre on application

Hi,

My C# application (form based, winexe) displays MessageBoxes at certain
times. At the moment it centres them on the screen; I want them centered
on the application.

This version (below) of MessageBox.Show should do this for me but I
can't seem to work out what the 1st parameter should be.

public static DialogResult Show(
IWin32Window owner,
string text, string caption,
MessageBoxButtons buttons, MessageBoxIcon icon);

MessageBox.Show( ??WHAT-GOES-HERE??,
"Text", "Text", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

I can't work out what the 1st paramaters variable should be.
'this.Handle' does not work.
Thanks and regards,

Pirmin
Nov 16 '05 #1
2 8067
Havent test it but have you tried to add the Form of the main GUI in it?

Add
private Form mainform = new MyApp();
into the class

MessageBox.Show( mainform,
"Text", "Text", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
"Pirmin G." <pi******@gmx.de> schrieb im Newsbeitrag
news:c6**********@zrha108x.zrh.siemens.ch... Hi,

My C# application (form based, winexe) displays MessageBoxes at certain
times. At the moment it centres them on the screen; I want them centered
on the application.

This version (below) of MessageBox.Show should do this for me but I
can't seem to work out what the 1st parameter should be.

public static DialogResult Show(
IWin32Window owner,
string text, string caption,
MessageBoxButtons buttons, MessageBoxIcon icon);

MessageBox.Show( ??WHAT-GOES-HERE??,
"Text", "Text", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

I can't work out what the 1st paramaters variable should be.
'this.Handle' does not work.
Thanks and regards,

Pirmin

Nov 16 '05 #2
Pirmin G. wrote:
Hi,

My C# application (form based, winexe) displays MessageBoxes at
certain times. At the moment it centres them on the screen; I want
them centered on the application.

This version (below) of MessageBox.Show should do this for me but I
can't seem to work out what the 1st parameter should be.

public static DialogResult Show(
IWin32Window owner,
string text, string caption,
MessageBoxButtons buttons, MessageBoxIcon icon);

MessageBox.Show( ??WHAT-GOES-HERE??,
"Text", "Text", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

I can't work out what the 1st paramaters variable should be.
'this.Handle' does not work.


Just pass this.
--
Tom Porterfield
MS-MVP MCE
http://support.telop.org

Please post all follow-ups to the newsgroup only.
Nov 16 '05 #3

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

Similar topics

7
by: Bill | last post by:
For some reason, I have an errormessage popup that "blinks", but pops up BEHIND the applications, which is confusing to users. Is there any way to force it to the top?
2
by: Jeff Van Epps | last post by:
We've been unable to get events working going from C# to VJ++. We think that the C# component is being exposed properly as a ConnectionPoint, and the Advise() from the VJ++ side seems to be...
0
by: chathurangakw | last post by:
Hi , I'm working on a smart client application. In one of my forms I have a socket instance which listens for any messages from others and there are some other windows forms too. when the...
4
by: Richard | last post by:
Hi All, I am using Visual C++ .Net to create a windows forms application and I am getting the following errors when I do a MessageBox::Show in my Form1.cpp file: Form1.cpp(19): error C2653:...
13
by: dbuchanan | last post by:
Hello, Here is the error message; ---------------------------- Exception Message: ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child key values (5) to exist in the...
3
by: Kiyomi | last post by:
Hello, I use in my application MessageBox.Show and it works perfectly when I run this application on my local computer (http://localhost). When I diployed this application on the server,...
2
by: Que | last post by:
Hi I have a form that catches an exception and throws a Messagebox Is it possible to throw the message box to center in the form that throws the exception Like Centre in parent form or...
3
by: rdemyan via AccessMonster.com | last post by:
Sometimes users (including myself) accidentally click on the application close icon in the application menu bar when they meant to just click on the 'X' for the form. Of course the app closes and...
2
by: hgarg | last post by:
The onpaint() is getting called before calculating the required parameters by listBox1_SelectedIndexChanged function. I tried calling it at the end of this function. But of no use. Due to this issue...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.