U: frameless for windows LCL, Border style reflects,

This commit is contained in:
杨红岩 2024-08-07 13:44:13 +08:00
parent 00fdcd0a8a
commit d46f3f043c
3 changed files with 13 additions and 21 deletions

View File

@ -44,16 +44,21 @@ func (m *LCLBrowserWindow) wndProc(hwnd types.HWND, message uint32, wParam, lPar
// See: https://docs.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmextendframeintoclientarea#remarks
extendFrameIntoClientArea(m.Handle(), margins{CxLeftWidth: 1, CxRightWidth: 1, CyTopHeight: 1, CyBottomHeight: 1})
case messages.WM_NCCALCSIZE:
// Disable the standard frame by allowing the client area to take the full
// window size.
// Trigger condition: Change the window size
// Disable the standard frame by allowing the client area to take the full window size.
// See: https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-nccalcsize#remarks
// This hides the titlebar and also disables the resizing from user interaction because the standard frame is not
// shown. We still need the WS_THICKFRAME style to enable resizing from the frontend.
if wParam != 0 {
//cycaption := win.GetSystemMetrics(4)
//rect := (*types.TRect)(unsafe.Pointer(lParam))
//rect.Bottom += -1
//rect.Right += -1
// Content overflow screen issue when maximizing borderless windows
// See: https://github.com/MicrosoftEdge/WebView2Feedback/issues/2549
//isMinimize := uint32(win.GetWindowLong(m.Handle(), win.GWL_STYLE))&win.WS_MINIMIZE != 0
isMaximize := uint32(win.GetWindowLong(m.Handle(), win.GWL_STYLE))&win.WS_MAXIMIZE != 0
if isMaximize {
rect := (*types.TRect)(unsafe.Pointer(lParam))
workRect := m.Monitor().WorkareaRect()
*rect = workRect
}
return 0
}
}

View File

@ -151,7 +151,7 @@ func (m *LCLBrowserWindow) doOnRenderCompMsg(chromiumBrowser ICEFChromiumBrowser
// 判断当前鼠标是否在边框范围
// 窗口边框和CEF组件边框
handled := m.cwcap.onCanBorder(chromiumBrowser, x, y, &rect)
handled := m.cwcap.onCanBorder(chromiumBrowser, x, y, rect)
if handled {
// 鼠标在边框位置
*lResult = types.LRESULT(m.cwcap.borderHT)

View File

@ -50,19 +50,6 @@ func (m *customWindowCaption) onNCMouseMove(hWND types.HWND, message *types.TMes
} else if m.canBorder { // 当前在边框
*lResult = types.LRESULT(m.borderHT)
*aHandled = true
//全屏时不允许移动窗口
// TODO 暂时不使用,配合 WndProc
//if m.bw.WindowProperty().current.ws == types.WsFullScreen {
// return
//}
//s := winapi.GetKeyState(winapi.VK_LBUTTON) & 0x800
//if winapi.GetKeyState(winapi.VK_LBUTTON) < 0 {
// x, y := m.toPoint(message)
// m.borderMD = true
// if win.ReleaseCapture() {
// win.PostMessage(hWND, messages.WM_SYSCOMMAND, uintptr(messages.SC_SIZE|m.borderWMSZ), rtl.MakeLParam(uint16(x), uint16(y)))
// }
//}
}
}
@ -91,7 +78,7 @@ func (m *customWindowCaption) onSetCursor(message *types.TMessage, lResult *type
}
// 鼠标是否在边框,并返回当前鼠标样式
func (m *customWindowCaption) onCanBorder(chromiumBrowser ICEFChromiumBrowser, x, y int32, windowRect *types.TRect) bool {
func (m *customWindowCaption) onCanBorder(chromiumBrowser ICEFChromiumBrowser, x, y int32, windowRect types.TRect) bool {
width := windowRect.Width()
height := windowRect.Height()
bda := chromiumBrowser.BroderDirectionAdjustments()