feat: 更新业务、控件及单据功能
This commit is contained in:
@@ -64,24 +64,35 @@ namespace Lskj.Control
|
||||
private void bsClient_OnCreated(object sender, EventArgs e)
|
||||
{
|
||||
cefBrowserSettings = (CefBrowser)sender;
|
||||
var handle = cefBrowserSettings.GetHost().GetWindowHandle();
|
||||
ResizeWindow(handle, this.Width, this.Height);
|
||||
SyncBrowserBounds();
|
||||
}
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
if (cefBrowserSettings != null)
|
||||
SyncBrowserBounds();
|
||||
}
|
||||
/// <summary>
|
||||
/// 将CEF原生子窗口同步到当前控件的客户区,修正高DPI或父容器布局变化造成的位置偏移。
|
||||
/// </summary>
|
||||
public void SyncBrowserBounds()
|
||||
{
|
||||
if (cefBrowserSettings == null || IsDisposed || Disposing ||
|
||||
ClientSize.Width <= 0 || ClientSize.Height <= 0)
|
||||
{
|
||||
ResizeWindow(cefBrowserSettings.GetHost().GetWindowHandle(), Width, Height);
|
||||
return;
|
||||
}
|
||||
|
||||
ResizeWindow(cefBrowserSettings.GetHost().GetWindowHandle(), ClientSize.Width, ClientSize.Height);
|
||||
}
|
||||
public void ResizeWindow(IntPtr handle, int width, int height)
|
||||
{
|
||||
if (handle != IntPtr.Zero)
|
||||
{
|
||||
const uint SWP_NOZORDER = 0x0004;
|
||||
const uint SWP_NOACTIVATE = 0x0010;
|
||||
NativeMethod.SetWindowPos(handle, IntPtr.Zero,
|
||||
0, 0, width, height,
|
||||
0x0002 | 0x0004
|
||||
SWP_NOZORDER | SWP_NOACTIVATE
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user