public partial class PatiCtlPacsReport : UserControl
{
private const int GWL_STYLE = (-16);
private const int WS_VISIBLE = 0x10000000 | 0x00800000 | 0x02000000 | 0x01000000;
private const int WS_VISIBLE2 = 0x40000000 | 0x00800000 | 0x02000000 | 0x01000000 | 0x10000000;
[DllImport("User32.dll", EntryPoint = "SetParent")]
private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll", EntryPoint = "ShowWindow")]
private static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
[DllImport("user32.dll", EntryPoint = "FindWindow")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", EntryPoint = "SetWindowLong", CharSet = CharSet.Auto)]
public static extern IntPtr SetWindowLongPtr32(HandleRef hWnd, int nIndex, int dwNewLong);
[DllImport("user32.dll", EntryPoint = "SetWindowLongPtr", CharSet = CharSet.Auto)]
public static extern IntPtr SetWindowLongPtr64(HandleRef hWnd, int nIndex, int dwNewLong);
[DllImport("user32.dll", SetLastError = true)]
private static extern bool MoveWindow(IntPtr hwnd, int x, int y, int cx, int cy, bool repaint

该博客介绍了如何在Winform窗体中嵌入并控制外部的exe程序,通过使用DllImport导入用户32.dll库的方法,实现SetParent、ShowWindow等函数,改变窗口样式和父窗口设置,达到在窗体中显示外部程序的目的。示例代码展示了如何查找并设置窗口的可见性、大小和位置。
最低0.47元/天 解锁文章
9927

被折叠的 条评论
为什么被折叠?



