如何检查是否已加载从DLL加载的WinFrom。 [英] How to check if a WinFrom loaded from a DLL is already loaded.
本文介绍了如何检查是否已加载从DLL加载的WinFrom。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一个DLL加载到第三方应用程序(AutoCAD)。加载后,我可以触发命令加载winforms以在AutoCAD中执行操作。
我的一个命令加载一个对话框。
我如何测试该对话框是否已经运行并且没有再次加载Winform并且只是将其激活/在所有其他应用程序之上?
在此先感谢。
Stephan
Hi Guys,
I have a DLL loaded into a 3rd Party application (AutoCAD). Once loaded i can trigger commands to load winforms to do things with in AutoCAD.
One of my commands loads a dialog.
How I Test if that Dialog is already running and not load the Winform again and just make it active / on top of all other applications?
Thanks in advance.
Stephan
推荐答案
嗨Stephan,
如果你想找到特定的表格已经打开或有效。以下内容可能会对您有所帮助。
Hi Stephan,
if you want to find particular form is already opened or active. i thing the following may help you.
List<MyForm> CurrentActiveForms = System.Windows.Forms.Application.OpenForms.OfType<MyForm>().ToList();
if(CurrentActiveForms.Count == 0)
{
// No match form found !!!!
// request a new form to open
return;
}
// do your stuff here........
MyForm DesireForm = CurrentActiveForms.FirstOrDefault(I => I.MyCondition == myCondition);
Or
MyForm DesireForm = CurrentActiveForms[0];
if (DesireForm != null || DesireForm.IsDisposed == false)
{
DesireForm.focus();
}
这篇关于如何检查是否已加载从DLL加载的WinFrom。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文