【发布时间】:2015-08-10 06:36:16
【问题描述】:
在这里,我试图在窗口窗体的面板中运行一些基于窗口的应用程序,并允许我在其中最小化它。 我能够在这个“notepad.exe”中运行和最小化,但不能使用 win 应用程序。
这是我的参考代码(仅适用于记事本):
[DllImport("USER32.DLL")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);[DllImport("USER32.dll")]
private static extern bool MoveWindow(IntPtr hwnd, int x, int y, int cx, int cy, bool repaint);
Process process = Process.Start("someapp.exe");
process.WaitForInputIdle();
SetParent(process.MainWindowHandle, this.panel1.Handle);
MoveWindow(process.MainWindowHandle, 0, 0, this.Width - 90, this.Height, true);
请告诉我是否有可能实现以及如何实现?
【问题讨论】:
-
我会建议避免这样的事情(阅读this 和谷歌一般的“oldnewthing”和“SetParent”)看看为什么。我最喜欢的名言“这在技术上是合法的。......玩电锯在技术上也是合法的。”
-
所以基本上这是可能的,但不是一个好主意,对吧?
标签: c#