系统对话框未显示 [英] System Dialogs Not Showing

查看:86
本文介绍了系统对话框未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows 7(x64,但应用程序是x86)(和两台不同的机器。)



每当我使用内置对话框(或MessageBox,for那个问题是没有出现。



我试过.ShowDialog()和.ShowDialog(这个)都无济于事。



但是,如果我在对话框出现后短暂点击ALT键,它会神奇地出现。同样,如果我打开,关闭,移动任何其他可用的应用程序。例如,IE或Chrome。这就像系统在显示对话框之前等待其他事情发生。



我已经通过制作自己的消息来消除MessageBox的使用,所以这不再是问题了...但我没有FolderBrowserDialog的替代品。



到底是怎么回事?有什么想法吗?

Windows 7 (x64, but the app is x86) (And two different machines.)

Whenever I use a built-in dialog (or MessageBox, for that matter) is does not appear.

I've tried both .ShowDialog() and .ShowDialog(this) to no avail.

BUT, if I briefly tap the ALT key after the dialog is supposed to show up, it magically appears. Likewise if I open, close, move any other application that's available. For instance, IE or Chrome. It's like the system is waiting until something else happens before showing the dialog.

I've eliminated the use of MessageBox by making my own, so that's not a problem anymore... But I don't have an alternative to the FolderBrowserDialog.

What the heck is going on? Any ideas?

推荐答案

好的。奇怪的问题,奇怪的解决方案。



主窗体上的菜单有一个自定义渲染器:



private class MyRenderer:ToolStripProfessionalRenderer

{

protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)

{

if(!e .Item.Selected)

{

base.OnRenderMenuItemBackground(e);

e.Item.ForeColor = Color.White;

e.Item.BackgroundImage = AMSIOS.Properties.Resources.BGTile;

}

else

{

e.Item.ForeColor = Color.Black;

e.Item.BackgroundImage = AMSIOS.Properties.Resources.BG;

Rectangle rc = new Rectangle( Point.Empty,e.Item.Size);

e.Graphics.FillRectangle(Brushes.DarkGray,rc);

e.Graphics.DrawRectangle(Pens.White,1,0,rc.Width - 2,rc.Height - 1);

}

}

}



追踪执行(F11,而不是F10)我看到主菜单正在重新绘制并重新绘制并重新绘制,没有明显的原因。那时主要形式甚至无法访问,为什么要重新渲染呢?现在我只需弄清楚为什么那个(被盗的)代码导致了对话框问题。



谢谢,全部。
OK. Weird problem, weird solution.

The menu on the main form had a custom renderer:

private class MyRenderer : ToolStripProfessionalRenderer
{
protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
{
if (!e.Item.Selected)
{
base.OnRenderMenuItemBackground(e);
e.Item.ForeColor = Color.White;
e.Item.BackgroundImage = AMSIOS.Properties.Resources.BGTile;
}
else
{
e.Item.ForeColor = Color.Black;
e.Item.BackgroundImage = AMSIOS.Properties.Resources.BG;
Rectangle rc = new Rectangle(Point.Empty, e.Item.Size);
e.Graphics.FillRectangle(Brushes.DarkGray, rc);
e.Graphics.DrawRectangle(Pens.White, 1, 0, rc.Width - 2, rc.Height - 1);
}
}
}

Tracing through the execution (F11, rather than F10) and I saw the main menu was being redrawn and redrawn and redrawn for no apparent reason. The main form isn't even accessible at that point, so why was it rerendering it? Now I just have to figure out why that (stolen) code caused the dialog box problems.

Thanks, all.


这篇关于系统对话框未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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