SVN r787
SVN-Revision: r787
This commit is contained in:
@@ -38,6 +38,20 @@ namespace Lskj.Util
|
||||
/// </summary>
|
||||
public static class HandleHelper
|
||||
{
|
||||
const int GWL_STYLE = -16;
|
||||
const int WS_BORDER = 0x00800000;
|
||||
const int WS_DLGFRAME = 0x00400000;
|
||||
const int WS_CAPTION = WS_BORDER | WS_DLGFRAME;
|
||||
const int WS_THICKFRAME = 0x00040000;
|
||||
const int WS_MINIMIZE = 0x20000000;
|
||||
const int WS_MAXIMIZEBOX = 0x00010000;
|
||||
const int WS_SYSMENU = 0x00080000;
|
||||
const uint SWP_NOMOVE = 0x0002;
|
||||
const uint SWP_NOSIZE = 0x0001;
|
||||
const uint SWP_NOZORDER = 0x0004;
|
||||
const uint SWP_FRAMECHANGED = 0x0020;
|
||||
const int SW_HIDE = 0;
|
||||
const int SW_SHOW = 5;
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int GetDpiForWindow(IntPtr hwnd);
|
||||
[DllImport("shell32.dll")]
|
||||
@@ -242,6 +256,36 @@ namespace Lskj.Util
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置一个进程为无边框并且嵌入到指定的控件中
|
||||
/// </summary>
|
||||
/// <param name="exeMainHandle"></param>
|
||||
public static void SetFormNoneStyle(IntPtr exeMainHandle, System.Windows.Forms.Control control)
|
||||
{
|
||||
// 移除窗口边框和标题栏
|
||||
//int style = GetWindowLong(exeMainHandle, GWL_STYLE);
|
||||
//style &= ~WS_CAPTION;
|
||||
//style &= ~WS_THICKFRAME;
|
||||
//style &= ~WS_MINIMIZE;
|
||||
//style &= ~WS_MAXIMIZEBOX;
|
||||
//style &= ~WS_SYSMENU;
|
||||
//SetWindowLong(exeMainHandle, GWL_STYLE, style);
|
||||
// 使样式更新生效
|
||||
//SetWindowPos(exeMainHandle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
|
||||
// 将exe窗口设置为panel的子窗口
|
||||
SetParent(exeMainHandle, control.Handle);
|
||||
// 调整大小填充panel
|
||||
ResizeEmbeddedWindow(exeMainHandle, control);
|
||||
// 最后显示嵌入窗口
|
||||
ShowWindow(exeMainHandle, SW_SHOW);
|
||||
//JobControl clsJobControl = new JobControl();
|
||||
//clsJobControl.AddProcess(control.Handle);
|
||||
// 自动响应panel大小变化调整嵌入窗口大小
|
||||
control.Resize += (s, e) =>
|
||||
{
|
||||
ResizeEmbeddedWindow(exeMainHandle, control);
|
||||
};
|
||||
}
|
||||
public static readonly Predicate<WindowInfo> DefaultPredicate = x => x.IsVisible && !x.IsMinimized && x.Title.Length > 0;
|
||||
}
|
||||
public class JobControl
|
||||
|
||||
Reference in New Issue
Block a user