简体   繁体   English

ShowDialog(所有者)隐藏在/不显示,即使我正在提供所有者IWin32Window

[英]ShowDialog(owner) is hiding behind/not showing even though I am supplying owner IWin32Window

Please do not close the question straight away. 请不要马上关闭这个问题。 The almost similar problem is also discussed in the following threads. 在以下线程中也讨论了几乎相似的问题。

  1. Windows Forms and ShowDialog problem Windows窗体和ShowDialog问题
  2. Form.ShowDialog() or Form.ShowDialog(this)? Form.ShowDialog()或Form.ShowDialog(this)?

But, these do not solve my problem. 但是,这些并不能解决我的问题。 The problem never occurred in my development machine. 我的开发机器中从未发生过这个问题。 It occurred in the user machine but not always. 它发生在用户机器上,但并非总是如此。 In fact it occurred only 3 or 4 times. 实际上它只发生了3到4次。

When it happens it seems the application/calling form is frozen. 当它发生时,似乎应用程序/调用表单被冻结。 If I can guess (as I am not seeing it on the screen) where the close button is and click on it on the called form, it closes and application goes back to usable state until it occurs again. 如果我可以猜测(因为我没有在屏幕上看到它)关闭按钮所在的位置并在被调用的表单上单击它,它将关闭并且应用程序将返回到可用状态,直到它再次出现。

My views are encapsulated within the presenter, so I am not calling ShowDialog() from within the view but through the presenter. 我的视图封装在演示者中,因此我不是从视图中调用ShowDialog()而是通过演示者调用。

MainPresenter
{
    MainPresenter(IMainView view)
    {
        _view = view;
    }
    …
    …
    OpenSecondView()
    {
        var secondPresenter =_presenterFactory.Create<SecondPresenter>();
        secondPresenter.Ininialize(_view);
    }
}

// Initialize method in the SecondPresenter
Initialize(owner)
{
    _secondView.ShowDialog(owner); 
}

I am using observing presenter style of MVP explained here http://www.aspiringcraftsman.com/2008/11/23/model-view-presenter-styles/ 我正在使用观察主持人风格的MVP解释http://www.aspiringcraftsman.com/2008/11/23/model-view-presenter-styles/

Questions: 问题:

  1. How can I reproduce the problem in my development machine and fix it? 如何在我的开发机器中重现问题并修复它?
  2. If I use Show() and set TopMost = true , is it possible this problem to occur? 如果我使用Show()并设置TopMost = true ,是否可能出现此问题?
  3. What are the things I should consider that may cause this problem? 我应该考虑哪些因素可能导致这个问题?

If Show() absolutely guarantees that the problem will not occur, I will go with Show() . 如果Show()绝对保证不会出现问题,我将使用Show() I kind of lost faith in ShowDialog() on this. 我对ShowDialog()对此失去了信心。

Any help will be greatly appreciated. 任何帮助将不胜感激。


** The problem does not occur for a specific screen/view. **特定屏幕/视图不会出现此问题。 It occurs randomly. 它随机发生。

** For all the forms except main form, ShowInTaskBar is set to false. **对于除主窗体之外的所有窗体,ShowInTaskBar设置为false。

您是否尝试在表单的load事件中添加this.Activate() ,因为我遇到了类似的问题。

您可以尝试使用TopMost = true作为表单

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM