Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   Floating and Position-controlled Dialog Box (http://www.go4expert.com/forums/floating-position-controlled-dialog-box-t3987/)

Coffee99 22Apr2007 22:46

Floating and Position-controlled Dialog Box
 
I'm new to C# but I need to make a floating messagebox that I can position from the code. My code so far pops up the message box and waits for user input. But it does not float above other windows and it does not come up where I want it to. So far I have:

DialogResult dir = MessageBox.Show("Keep Going?", "Coninue" ,MessageBoxButtons.YesNoCancel);
if (dir == DialogResult.No)
{
Console.WriteLine(" We are NOT done " ) ;
}


Thanks for your help.

shabbir 23Apr2007 04:56

Re: Floating and Position-controlled Dialog Box
 
You need to specify the parent window to the MessageBox to make it above the current window.

Something like
Code:

MessageBox.Show (IWin32Window, String, String, MessageBoxButtons)
Displays a message box in front of the specified object identified by IWin32Window and rest of the params are same as used by you.

Coffee99 23Apr2007 06:46

Re: Floating and Position-controlled Dialog Box
 
The field "IWin32Window" is unknown to compiler. Do I need ot incldue another "using " ?

shabbir 23Apr2007 07:57

Re: Floating and Position-controlled Dialog Box
 
What do you mean by unknown to compiler.

Coffee99 24Apr2007 03:22

Re: Floating and Position-controlled Dialog Box
 
I get error:

System.Windows.Forms.IWin32Window is a 'type' but used like a variable

Not sure what to do.

gary

shabbir 24Apr2007 08:59

Re: Floating and Position-controlled Dialog Box
 
That is the type of parameter and you need to pass the this pointer provided you are calling the function in the Window class (Form or something similar)


All times are GMT +5.5. The time now is 11:35.