我的工作应该做在启动以下应用:隐藏父窗口,但显示的子窗口
- 连接到使用COM软件(AutoCAD)的外部应用程序。
- 发送消息给应用程序来运行一些DLL代码(打开一个窗口)。
- 隐藏AutoCAD的窗口,但保持DLL的窗口可见。
我已经成功完成了前两个步骤,但第三个给了我一些问题。
我不知道是否有可能让子窗口可见而父窗口不可见。每当我让孩子看到或使其成为最顶层窗口时,AutoCAD也会变得可见。
我的目标是运行我的DLL代码,但保持AutoCAD在后台运行,对用户完全不可见。 DLL必须通过AutoCAD加载,因为它允许我使用AutoCAD的.NET接口而不是COM。
在任何情况下,我很好奇我是否有可能通过一些Windows API调用或.NET中的某些东西来实现。 PS:我不确定这个窗口关系是否真的是父母 - 孩子之间的关系。我假设它是因为我的窗口属于AutoCAD应用程序实例,由于DLL加载。
任何帮助,非常感谢。谢谢! :)
编辑: DLL的代码来创建一个窗口。
//CommandMethod is an AutoCAD attribute for entering into the DLL. This code is called
//when the user attempts the command "AUTOCADCOMMANDNAME" or can be done by simulating
//the command programmatically.
[CommandMethod("AUTOCADCOMMANDNAME", CommandFlags.Session)]
public void CommandEntry()
{
MainWindow mainWin = new MainWindow();
mainWin.ShowDialog();
}
主应用程序代码
public static void Main()
{ //Use a utility class to create a connection to AutoCAD via COM
AcadApplication acadApp = ACUtil.GetAcadInstance(out createdNewInstance);
acadApp.Visible = false;
//Irrelevant code omitted...
acadApp.ActiveDocument.SendCommand("AUTOCADCOMMANDNAME");
acadApp.Quit(); //Exit AutoCAD application
//Note: doesn't quit until mainWin closes because of ShowDialog()
}
你需要证明创建DLL中的窗口中的代码。 –
完成,虽然窗口没有以任何奇特的方式初始化:P –