Getting MessageBox to centre on application

  • Thread starter Thread starter Pirmin G.
  • Start date Start date
P

Pirmin G.

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
 
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,
 
Pirmin said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top