是否可以使用DialogResult方法将“父"窗口设置为MessageBox Alert. [英] Is it possible to set Parent window to MessageBox Alert using DialogResult method..?

查看:132
本文介绍了是否可以使用DialogResult方法将“父"窗口设置为MessageBox Alert.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



是否将父窗口"设置为"MessageBox Alert".(不是Java语言)?
警报框在C#编码中使用DialogResult ...
这是我的代码:

Hi,

is it set Parent window to MessageBox Alert..(Not in Javascript)?
Alert box Using DialogResult in C# coding...
Here is my code:

DialogResult result=MessageBox.Show(""+"",MessageBoxButtons.OKCancel,MessageBoxIcon.Information);
if(result==DialogResult.OK)
{///Redirect something;}
else
{///something}


上面的代码可以正常工作,但是如果我们运行的窗口多于Windows,则显示警告框...通过此代码可以将窗口或父窗口设置为前面吗?
在此先感谢...


above code is working fine, but if we run more than windows,alert box back to display... Through this code Is possible set front of window or parent...?

Thanks in Advance...

推荐答案

根据需要,您通常会在
MsgBox 

中使用参数MB_TOPMOSTMB_SYSTEMMODALMB_TASKMODAL Win api方法.
http://msdn.microsoft.com/en-us/library/sfw6660x%28v = vs.85%29.aspx [ ^ ]

但是这里的一篇文章中给出了另一种解决方案,以使消息框位于顶部:
TopMost消息框 [

win api method.
http://msdn.microsoft.com/en-us/library/sfw6660x%28v=vs.85%29.aspx[^]

But another solution for this is given here in an article to keep the message box on top:
TopMost MessageBox[^]

Good luck!


< pre lang ="xml">& lt; pre& gt;& lt//pre& gt;再次部署我的应用程序...错误....
任何人都可以帮助解决这个问题......
这是我的代码...
< pre lang =& quot; C ++"" DialogResult结果= TopMostMessageBox.Show(& amp; quot;您的密码将在& amp; quot;和& amp; "& amp;" + Futdays +& amp;& amp"" +& amp;"Day&s& amp"" +& amp;#39; \ n& ; amp;#39; +& amp; quot;是否要立即更改?& amp; quot;,& amp; quot;财务管理系统& amp; quot ;、
MessageBoxButtons.YesNo,MessageBoxIcon.Question,MessageBoxDefaultButton.Button1,
MessageBoxOptions.ServiceNotification);</pre& gt;


< pre lang =& quot; C ++& gt;"静态公共DialogResult显示(字符串消息,字符串标题,MessageBoxButtons按钮,MessageBoxIcon图标,MessageBoxDefaultButton Btn,MessageBoxOptions选项)
{
//创建一个宿主窗体,该宿主窗体是TopMost窗口,它将是
//MessageBox的父级.
表单topmostForm = new Form();
//我们不希望任何人看到此窗口,因此请将其置于
附近 //可见的屏幕,并使其尽可能小
topmostForm.Size =新的System.Drawing.Size(1,1);
topmostForm.StartPosition = FormStartPosition.Manual;
System.Drawing.Rectangle rect = SystemInformation.VirtualScreen;
topmostForm.Location =新的System.Drawing.Point(rect.Bottom + 10,
rect.Right + 10);
//topmostForm.ShowDialog();
topmostForm.Show();
//将此表格设为活动表格,并将其设为TopMost
topmostForm.Focus();
topmostForm.BringToFront();
topmostForm.TopMost = true;
//topmostForm.
//最后显示带有刚创建的表单的MessageBox作为其所有者
< b& gt; DialogResult结果= MessageBox.Show(topmostForm,消息,标题,按钮,图标,Btn,opt);</b>///////错误此区域. .
topmostForm.Dispose();返回结果;
}& lt;/pre& gt;

现在,纠正了服务通知错误...但以下错误却出现了...
< b& gt;显示带有所有者窗口的服务通知消息框是无效操作.使用不带下位符号的shoe方法.参数名称:options</b& gt;</pre> ;
<pre lang="xml">&lt;pre&gt;&lt;/pre&gt;While i deploy my application...Again error....
Anybbody help and solve this problem......
Here my code...
&lt;pre lang=&quot;C++&quot;&gt;DialogResult result = TopMostMessageBox.Show(&amp;quot;Your Password will Expire in&amp;quot; + &amp;quot; &amp;quot; + Futdays + &amp;quot; &amp;quot; + &amp;quot;Day(s)&amp;quot; + &amp;#39;\n&amp;#39; + &amp;quot;Do you want Change it now?&amp;quot;, &amp;quot;Financial Management System&amp;quot;,
MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1,
MessageBoxOptions.ServiceNotification);&lt;/pre&gt;


&lt;pre lang=&quot;C++&quot;&gt;static public DialogResult Show(string message, string title, MessageBoxButtons buttons, MessageBoxIcon Icon,MessageBoxDefaultButton Btn,MessageBoxOptions Opt)
{
// Create a host form that is a TopMost window which will be the
// parent of the MessageBox.
Form topmostForm = new Form();
// We do not want anyone to see this window so position it off the
// visible screen and make it as small as possible
topmostForm.Size = new System.Drawing.Size(1, 1);
topmostForm.StartPosition = FormStartPosition.Manual;
System.Drawing.Rectangle rect = SystemInformation.VirtualScreen;
topmostForm.Location = new System.Drawing.Point(rect.Bottom + 10,
rect.Right + 10);
//topmostForm.ShowDialog();
topmostForm.Show();
// Make this form the active form and make it TopMost
topmostForm.Focus();
topmostForm.BringToFront();
topmostForm.TopMost = true;
//topmostForm.
// Finally show the MessageBox with the form just created as its owner
&lt;b&gt;DialogResult result = MessageBox.Show(topmostForm, message, title,buttons,Icon,Btn,opt);&lt;/b&gt;//////error this area...
topmostForm.Dispose(); return result;
}&lt;/pre&gt;

now Servive notifiaction error corrected.. but below error appered...
&lt;b&gt;Show a service notification messagebox with an owner window is not a valid operation.Use the shoe method that does not take an ower.Parameter name:options&lt;/b&gt;</pre>


任何机构只有在部署后才会遇到此错误.不仅本地计算机...

当应用程序不在UserInteractive模式下运行时,显示模式对话框或窗体是无效操作.指定ServiceNotification或DefaultDesktopOnly样式以显示...
Any body face this error only after deploying.. not only local machine...

Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a...


这篇关于是否可以使用DialogResult方法将“父"窗口设置为MessageBox Alert.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆