编辑于江苏南京2023年02月06号。
当运行自己的插件时,可以将catia置顶到桌面顶端的小代码,实现的效果如下。
代码实现的原理是找到Catia运行的进程,然后将进程显示到最前端。同样放在自定义类CatiaHelper中。
/// <summary>
///将catia界面放置到最前。
/// </summary>
public static void PushCatiaToUpper()
{
Process catiaProcess = null;
//Catia的进程名是“CNEXT”
string catiaProcessName = "CNEXT";
foreach (Process index in Process.GetProcesses())
{
if (index.ProcessName==catiaProcessName)
{
catiaProcess = index;
break;
}
}
//将catia界面移到显示的最前端
SwitchToThisWindow(catiaProcess.MainWindowHandle, true);
}
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool SwitchToThisWindow(IntPtr hWnd, bool fAltTab);