2023-01-07 21:29:08 +08:00
|
|
|
|
//----------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Copyright © yanghy. All Rights Reserved.
|
|
|
|
|
//
|
2023-02-19 23:21:47 +08:00
|
|
|
|
// Licensed under Apache License Version 2.0, January 2004
|
|
|
|
|
//
|
|
|
|
|
// https://www.apache.org/licenses/LICENSE-2.0
|
2023-01-07 21:29:08 +08:00
|
|
|
|
//
|
|
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
|
|
//go:build windows
|
|
|
|
|
|
2023-02-20 00:20:01 +08:00
|
|
|
|
// LCL窗口组件定义和实现-windows平台
|
2023-05-31 17:41:14 +08:00
|
|
|
|
|
2023-01-07 21:29:08 +08:00
|
|
|
|
package cef
|
|
|
|
|
|
2023-01-07 21:42:21 +08:00
|
|
|
|
import (
|
2023-06-11 00:10:55 +08:00
|
|
|
|
"github.com/energye/energy/v2/cef/winapi"
|
2023-05-31 18:00:34 +08:00
|
|
|
|
"github.com/energye/energy/v2/consts"
|
2023-06-10 19:22:06 +08:00
|
|
|
|
et "github.com/energye/energy/v2/types"
|
2023-01-18 08:37:08 +08:00
|
|
|
|
"github.com/energye/golcl/lcl"
|
|
|
|
|
"github.com/energye/golcl/lcl/rtl"
|
|
|
|
|
"github.com/energye/golcl/lcl/types"
|
2023-01-15 00:41:59 +08:00
|
|
|
|
"github.com/energye/golcl/lcl/win"
|
2023-01-07 21:42:21 +08:00
|
|
|
|
)
|
2023-01-07 21:29:08 +08:00
|
|
|
|
|
2023-02-12 17:28:31 +08:00
|
|
|
|
// 定义四角和边框范围
|
2023-01-22 20:44:48 +08:00
|
|
|
|
var (
|
|
|
|
|
angleRange int32 = 10 //四角
|
|
|
|
|
borderRange int32 = 5 //四边框
|
|
|
|
|
)
|
2023-01-18 08:54:22 +08:00
|
|
|
|
|
2023-02-20 00:20:01 +08:00
|
|
|
|
// customWindowCaption 自定义窗口标题栏
|
|
|
|
|
//
|
|
|
|
|
// 隐藏窗口标题栏,通过html+css实现自定义窗口标题栏,实现窗口拖拽等
|
2023-01-20 10:17:45 +08:00
|
|
|
|
type customWindowCaption struct {
|
2023-01-23 20:45:33 +08:00
|
|
|
|
bw *LCLBrowserWindow //
|
2023-01-22 21:39:04 +08:00
|
|
|
|
canCaption bool //当前鼠标是否在标题栏区域
|
|
|
|
|
canBorder bool //当前鼠标是否在边框
|
|
|
|
|
borderHT, borderWMSZ int //borderHT: 鼠标所在边框位置, borderWMSZ: 窗口改变大小边框方向 borderMD:
|
|
|
|
|
borderMD bool //borderMD: 鼠标调整窗口大小,已按下后,再次接收到132消息应该忽略该消息
|
|
|
|
|
regions *TCefDraggableRegions //窗口内html拖拽区域
|
2023-06-10 19:22:06 +08:00
|
|
|
|
rgn *et.HRGN //
|
2023-01-20 10:17:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-20 00:20:01 +08:00
|
|
|
|
// ShowTitle 显示标题栏
|
2023-01-07 21:29:08 +08:00
|
|
|
|
func (m *LCLBrowserWindow) ShowTitle() {
|
2023-02-12 17:28:31 +08:00
|
|
|
|
m.WindowProperty().EnableHideCaption = false
|
2023-01-18 14:34:07 +08:00
|
|
|
|
//win.SetWindowLong(m.Handle(), win.GWL_STYLE, uintptr(win.GetWindowLong(m.Handle(), win.GWL_STYLE)|win.WS_CAPTION))
|
|
|
|
|
//win.SetWindowPos(m.Handle(), m.Handle(), 0, 0, 0, 0, win.SWP_NOSIZE|win.SWP_NOMOVE|win.SWP_NOZORDER|win.SWP_NOACTIVATE|win.SWP_FRAMECHANGED)
|
2023-01-23 10:52:40 +08:00
|
|
|
|
m.EnabledMaximize(m.WindowProperty().EnableMaximize)
|
|
|
|
|
m.EnabledMinimize(m.WindowProperty().EnableMinimize)
|
2023-01-18 14:34:07 +08:00
|
|
|
|
m.SetBorderStyle(types.BsSizeable)
|
2023-01-07 21:29:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-20 00:20:01 +08:00
|
|
|
|
// HideTitle 隐藏标题栏
|
2023-01-07 21:29:08 +08:00
|
|
|
|
func (m *LCLBrowserWindow) HideTitle() {
|
2023-02-12 17:28:31 +08:00
|
|
|
|
m.WindowProperty().EnableHideCaption = true
|
2023-01-18 14:34:07 +08:00
|
|
|
|
//win.SetWindowLong(m.Handle(), win.GWL_STYLE, uintptr(win.GetWindowLong(m.Handle(), win.GWL_STYLE)&^win.WS_CAPTION))
|
|
|
|
|
//win.SetWindowPos(m.Handle(), 0, 0, 0, m.Width(), m.Height()+500, win.SWP_NOMOVE|win.SWP_NOZORDER|win.SWP_NOACTIVATE|win.SWP_FRAMECHANGED|win.SWP_DRAWFRAME)
|
2023-01-19 10:24:47 +08:00
|
|
|
|
//无标题栏情况会导致任务栏不能切换窗口,不知道为什么要这样设置一下
|
|
|
|
|
m.EnabledMaximize(false)
|
2023-01-18 14:34:07 +08:00
|
|
|
|
m.SetBorderStyle(types.BsNone)
|
|
|
|
|
|
2023-01-07 21:29:08 +08:00
|
|
|
|
}
|
2023-01-18 08:37:08 +08:00
|
|
|
|
|
2023-02-20 00:20:01 +08:00
|
|
|
|
// freeRgn
|
2023-01-20 10:16:38 +08:00
|
|
|
|
func (m *customWindowCaption) freeRgn() {
|
|
|
|
|
if m.rgn != nil {
|
2023-06-11 00:10:55 +08:00
|
|
|
|
winapi.WinSetRectRgn(m.rgn, 0, 0, 0, 0)
|
|
|
|
|
winapi.WinDeleteObject(m.rgn)
|
2023-01-20 10:16:38 +08:00
|
|
|
|
m.rgn.Free()
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-20 19:31:37 +08:00
|
|
|
|
|
2023-02-20 00:20:01 +08:00
|
|
|
|
// freeRegions
|
2023-01-20 10:16:38 +08:00
|
|
|
|
func (m *customWindowCaption) freeRegions() {
|
|
|
|
|
if m.regions != nil {
|
|
|
|
|
m.regions.regions = nil
|
|
|
|
|
m.regions = nil
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-20 19:31:37 +08:00
|
|
|
|
|
2023-02-20 00:20:01 +08:00
|
|
|
|
// free
|
2023-01-20 10:16:38 +08:00
|
|
|
|
func (m *customWindowCaption) free() {
|
|
|
|
|
if m != nil {
|
|
|
|
|
m.freeRgn()
|
|
|
|
|
m.freeRegions()
|
|
|
|
|
}
|
2023-01-18 08:37:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-20 00:20:01 +08:00
|
|
|
|
// onNCMouseMove NC 非客户区鼠标移动
|
2023-01-22 22:47:51 +08:00
|
|
|
|
func (m *customWindowCaption) onNCMouseMove(message *types.TMessage, lResult *types.LRESULT, aHandled *bool) {
|
|
|
|
|
if m.canCaption { // 当前在标题栏
|
|
|
|
|
} else if m.canBorder { // 当前在边框
|
|
|
|
|
*lResult = types.LRESULT(m.borderHT)
|
2023-01-22 20:44:48 +08:00
|
|
|
|
*aHandled = true
|
|
|
|
|
}
|
2023-01-22 10:03:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-20 00:20:01 +08:00
|
|
|
|
// onSetCursor 设置鼠标图标
|
2023-01-22 20:44:48 +08:00
|
|
|
|
func (m *customWindowCaption) onSetCursor(message *types.TMessage, lResult *types.LRESULT, aHandled *bool) {
|
|
|
|
|
if m.canBorder { //当前在边框
|
2023-06-11 00:10:55 +08:00
|
|
|
|
switch winapi.LOWORD(uint32(message.LParam)) {
|
2023-05-31 17:41:14 +08:00
|
|
|
|
case consts.HTBOTTOMRIGHT, consts.HTTOPLEFT: //右下 左上
|
2023-01-22 21:39:04 +08:00
|
|
|
|
*lResult = types.LRESULT(m.borderHT)
|
2023-01-22 20:44:48 +08:00
|
|
|
|
*aHandled = true
|
2023-06-11 00:10:55 +08:00
|
|
|
|
winapi.WinSetCursor(winapi.WinLoadCursor(0, winapi.IDC_SIZENWSE))
|
2023-05-31 17:41:14 +08:00
|
|
|
|
case consts.HTRIGHT, consts.HTLEFT: //右 左
|
2023-01-22 21:39:04 +08:00
|
|
|
|
*lResult = types.LRESULT(m.borderHT)
|
2023-01-22 20:44:48 +08:00
|
|
|
|
*aHandled = true
|
2023-06-11 00:10:55 +08:00
|
|
|
|
winapi.WinSetCursor(winapi.WinLoadCursor(0, winapi.IDC_SIZEWE))
|
2023-05-31 17:41:14 +08:00
|
|
|
|
case consts.HTTOPRIGHT, consts.HTBOTTOMLEFT: //右上 左下
|
2023-01-22 21:39:04 +08:00
|
|
|
|
*lResult = types.LRESULT(m.borderHT)
|
2023-01-22 20:44:48 +08:00
|
|
|
|
*aHandled = true
|
2023-06-11 00:10:55 +08:00
|
|
|
|
winapi.WinSetCursor(winapi.WinLoadCursor(0, winapi.IDC_SIZENESW))
|
2023-05-31 17:41:14 +08:00
|
|
|
|
case consts.HTTOP, consts.HTBOTTOM: //上 下
|
2023-01-22 21:39:04 +08:00
|
|
|
|
*lResult = types.LRESULT(m.borderHT)
|
2023-01-22 20:44:48 +08:00
|
|
|
|
*aHandled = true
|
2023-06-11 00:10:55 +08:00
|
|
|
|
winapi.WinSetCursor(winapi.WinLoadCursor(0, winapi.IDC_SIZENS))
|
2023-01-22 20:44:48 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-22 10:03:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-20 00:20:01 +08:00
|
|
|
|
// onCanBorder 鼠标是否在边框
|
2023-01-22 21:39:04 +08:00
|
|
|
|
func (m *customWindowCaption) onCanBorder(x, y int32, rect *types.TRect) (int, bool) {
|
2023-01-22 20:44:48 +08:00
|
|
|
|
if m.canBorder = x <= rect.Width() && x >= rect.Width()-angleRange && y <= angleRange; m.canBorder { // 右上
|
2023-06-11 00:10:55 +08:00
|
|
|
|
m.borderWMSZ = winapi.WMSZ_TOPRIGHT
|
2023-05-31 17:41:14 +08:00
|
|
|
|
m.borderHT = consts.HTTOPRIGHT
|
2023-01-22 21:39:04 +08:00
|
|
|
|
return m.borderHT, true
|
2023-01-22 20:44:48 +08:00
|
|
|
|
} else if m.canBorder = x <= rect.Width() && x >= rect.Width()-angleRange && y <= rect.Height() && y >= rect.Height()-angleRange; m.canBorder { // 右下
|
2023-06-11 00:10:55 +08:00
|
|
|
|
m.borderWMSZ = winapi.WMSZ_BOTTOMRIGHT
|
2023-05-31 17:41:14 +08:00
|
|
|
|
m.borderHT = consts.HTBOTTOMRIGHT
|
2023-01-22 21:39:04 +08:00
|
|
|
|
return m.borderHT, true
|
2023-01-22 20:44:48 +08:00
|
|
|
|
} else if m.canBorder = x <= angleRange && y <= angleRange; m.canBorder { //左上
|
2023-06-11 00:10:55 +08:00
|
|
|
|
m.borderWMSZ = winapi.WMSZ_TOPLEFT
|
2023-05-31 17:41:14 +08:00
|
|
|
|
m.borderHT = consts.HTTOPLEFT
|
2023-01-22 21:39:04 +08:00
|
|
|
|
return m.borderHT, true
|
2023-01-22 20:44:48 +08:00
|
|
|
|
} else if m.canBorder = x <= angleRange && y >= rect.Height()-angleRange; m.canBorder { //左下
|
2023-06-11 00:10:55 +08:00
|
|
|
|
m.borderWMSZ = winapi.WMSZ_BOTTOMLEFT
|
2023-05-31 17:41:14 +08:00
|
|
|
|
m.borderHT = consts.HTBOTTOMLEFT
|
2023-01-22 21:39:04 +08:00
|
|
|
|
return m.borderHT, true
|
2023-01-22 20:44:48 +08:00
|
|
|
|
} else if m.canBorder = x > angleRange && x < rect.Width()-angleRange && y <= borderRange; m.canBorder { //上
|
2023-06-11 00:10:55 +08:00
|
|
|
|
m.borderWMSZ = winapi.WMSZ_TOP
|
2023-05-31 17:41:14 +08:00
|
|
|
|
m.borderHT = consts.HTTOP
|
2023-01-22 21:39:04 +08:00
|
|
|
|
return m.borderHT, true
|
2023-01-22 20:44:48 +08:00
|
|
|
|
} else if m.canBorder = x > angleRange && x < rect.Width()-angleRange && y >= rect.Height()-borderRange; m.canBorder { //下
|
2023-06-11 00:10:55 +08:00
|
|
|
|
m.borderWMSZ = winapi.WMSZ_BOTTOM
|
2023-05-31 17:41:14 +08:00
|
|
|
|
m.borderHT = consts.HTBOTTOM
|
2023-01-22 21:39:04 +08:00
|
|
|
|
return m.borderHT, true
|
2023-01-22 20:44:48 +08:00
|
|
|
|
} else if m.canBorder = x <= borderRange && y > angleRange && y < rect.Height()-angleRange; m.canBorder { //左
|
2023-06-11 00:10:55 +08:00
|
|
|
|
m.borderWMSZ = winapi.WMSZ_LEFT
|
2023-05-31 17:41:14 +08:00
|
|
|
|
m.borderHT = consts.HTLEFT
|
2023-01-22 21:39:04 +08:00
|
|
|
|
return m.borderHT, true
|
2023-01-22 20:44:48 +08:00
|
|
|
|
} else if m.canBorder = x <= rect.Width() && x >= rect.Width()-borderRange && y > angleRange && y < rect.Height()-angleRange; m.canBorder { // 右
|
2023-06-11 00:10:55 +08:00
|
|
|
|
m.borderWMSZ = winapi.WMSZ_RIGHT
|
2023-05-31 17:41:14 +08:00
|
|
|
|
m.borderHT = consts.HTRIGHT
|
2023-01-22 21:39:04 +08:00
|
|
|
|
return m.borderHT, true
|
2023-01-22 20:44:48 +08:00
|
|
|
|
}
|
|
|
|
|
return 0, false
|
|
|
|
|
}
|
2023-01-22 10:03:37 +08:00
|
|
|
|
|
2023-02-20 00:20:01 +08:00
|
|
|
|
// onNCLButtonDown NC 鼠标左键按下
|
2023-01-22 20:44:48 +08:00
|
|
|
|
func (m *customWindowCaption) onNCLButtonDown(hWND types.HWND, message *types.TMessage, lResult *types.LRESULT, aHandled *bool) {
|
|
|
|
|
if m.canCaption { // 标题栏
|
2023-01-23 14:01:28 +08:00
|
|
|
|
x, y := m.toPoint(message)
|
2023-05-31 17:41:14 +08:00
|
|
|
|
*lResult = consts.HTCAPTION
|
2023-01-22 22:47:51 +08:00
|
|
|
|
m.borderMD = true
|
2023-01-22 20:44:48 +08:00
|
|
|
|
*aHandled = true
|
|
|
|
|
win.ReleaseCapture()
|
2023-05-31 17:41:14 +08:00
|
|
|
|
rtl.PostMessage(hWND, consts.WM_NCLBUTTONDOWN, consts.HTCAPTION, rtl.MakeLParam(uint16(x), uint16(y)))
|
2023-01-22 20:44:48 +08:00
|
|
|
|
} else if m.canBorder { // 边框
|
2023-01-23 14:01:28 +08:00
|
|
|
|
x, y := m.toPoint(message)
|
2023-01-22 22:47:51 +08:00
|
|
|
|
*lResult = types.LRESULT(m.borderHT)
|
2023-01-22 21:39:04 +08:00
|
|
|
|
m.borderMD = true
|
2023-01-22 20:44:48 +08:00
|
|
|
|
*aHandled = true
|
|
|
|
|
win.ReleaseCapture()
|
2023-05-31 17:41:14 +08:00
|
|
|
|
rtl.PostMessage(hWND, consts.WM_SYSCOMMAND, uintptr(consts.SC_SIZE|m.borderWMSZ), rtl.MakeLParam(uint16(x), uint16(y)))
|
2023-01-23 10:52:40 +08:00
|
|
|
|
//rtl.PostMessage(hWND, WM_SYSCOMMAND, uintptr(SC_SIZE|m.borderWMSZ), 0)
|
2023-01-22 20:44:48 +08:00
|
|
|
|
}
|
2023-01-22 10:03:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-20 00:20:01 +08:00
|
|
|
|
// toPoint 转换XY坐标
|
2023-01-23 14:01:28 +08:00
|
|
|
|
func (m *customWindowCaption) toPoint(message *types.TMessage) (x, y int32) {
|
2023-06-11 00:10:55 +08:00
|
|
|
|
return winapi.GET_X_LPARAM(message.LParam), winapi.GET_Y_LPARAM(message.LParam)
|
2023-01-18 08:37:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-20 00:20:01 +08:00
|
|
|
|
// isCaption
|
2023-02-12 17:28:31 +08:00
|
|
|
|
// 鼠标是否在标题栏区域
|
2023-01-24 12:23:03 +08:00
|
|
|
|
//
|
2023-02-12 17:28:31 +08:00
|
|
|
|
// 如果启用了css拖拽则校验拖拽区域,否则只返回相对于浏览器窗口的x,y坐标
|
2023-06-10 19:22:06 +08:00
|
|
|
|
func (m *customWindowCaption) isCaption(hWND et.HWND, message *types.TMessage) (int32, int32, bool) {
|
2023-01-18 08:37:08 +08:00
|
|
|
|
dx, dy := m.toPoint(message)
|
2023-06-10 19:22:06 +08:00
|
|
|
|
p := &et.Point{
|
2023-01-23 14:01:28 +08:00
|
|
|
|
X: dx,
|
|
|
|
|
Y: dy,
|
2023-01-18 08:37:08 +08:00
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
|
winapi.WinScreenToClient(hWND, p)
|
2023-01-23 20:45:33 +08:00
|
|
|
|
p.X -= m.bw.WindowParent().Left()
|
|
|
|
|
p.Y -= m.bw.WindowParent().Top()
|
2023-01-24 12:23:03 +08:00
|
|
|
|
if m.bw.WindowProperty().EnableWebkitAppRegion && m.rgn != nil {
|
2023-06-11 00:10:55 +08:00
|
|
|
|
m.canCaption = winapi.WinPtInRegion(m.rgn, p.X, p.Y)
|
2023-01-24 12:23:03 +08:00
|
|
|
|
} else {
|
|
|
|
|
m.canCaption = false
|
|
|
|
|
}
|
2023-01-18 08:37:08 +08:00
|
|
|
|
return p.X, p.Y, m.canCaption
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-20 00:20:01 +08:00
|
|
|
|
// doOnRenderCompMsg
|
2023-01-18 08:37:08 +08:00
|
|
|
|
func (m *LCLBrowserWindow) doOnRenderCompMsg(message *types.TMessage, lResult *types.LRESULT, aHandled *bool) {
|
2023-01-24 12:23:03 +08:00
|
|
|
|
switch message.Msg {
|
2023-05-31 17:41:14 +08:00
|
|
|
|
case consts.WM_NCLBUTTONDBLCLK: // 163 NC left dclick
|
2023-01-24 12:23:03 +08:00
|
|
|
|
//标题栏拖拽区域 双击最大化和还原
|
|
|
|
|
if m.cwcap.canCaption && m.WindowProperty().EnableWebkitAppRegionDClk {
|
2023-05-31 17:41:14 +08:00
|
|
|
|
*lResult = consts.HTCAPTION
|
2023-01-24 12:23:03 +08:00
|
|
|
|
*aHandled = true
|
|
|
|
|
win.ReleaseCapture()
|
2023-02-15 14:48:18 +08:00
|
|
|
|
m.windowProperty.windowState = m.WindowState()
|
|
|
|
|
if m.windowProperty.windowState == types.WsNormal {
|
2023-05-31 17:41:14 +08:00
|
|
|
|
rtl.PostMessage(m.Handle(), consts.WM_SYSCOMMAND, consts.SC_MAXIMIZE, 0)
|
2023-01-24 12:23:03 +08:00
|
|
|
|
} else {
|
2023-05-31 17:41:14 +08:00
|
|
|
|
rtl.PostMessage(m.Handle(), consts.WM_SYSCOMMAND, consts.SC_RESTORE, 0)
|
2023-01-18 08:37:08 +08:00
|
|
|
|
}
|
2023-05-31 17:41:14 +08:00
|
|
|
|
rtl.SendMessage(m.Handle(), consts.WM_NCLBUTTONUP, consts.HTCAPTION, 0)
|
2023-01-24 12:23:03 +08:00
|
|
|
|
}
|
2023-05-31 17:41:14 +08:00
|
|
|
|
case consts.WM_NCLBUTTONDOWN: // 161 nc left down
|
2023-01-24 12:23:03 +08:00
|
|
|
|
m.cwcap.onNCLButtonDown(m.Handle(), message, lResult, aHandled)
|
2023-05-31 17:41:14 +08:00
|
|
|
|
case consts.WM_NCLBUTTONUP: // 162 nc l up
|
2023-01-24 12:23:03 +08:00
|
|
|
|
if m.cwcap.canCaption {
|
2023-05-31 17:41:14 +08:00
|
|
|
|
*lResult = consts.HTCAPTION
|
2023-01-24 12:23:03 +08:00
|
|
|
|
*aHandled = true
|
|
|
|
|
}
|
2023-05-31 17:41:14 +08:00
|
|
|
|
case consts.WM_NCMOUSEMOVE: // 160 nc mouse move
|
2023-01-24 12:23:03 +08:00
|
|
|
|
m.cwcap.onNCMouseMove(message, lResult, aHandled)
|
2023-05-31 17:41:14 +08:00
|
|
|
|
case consts.WM_SETCURSOR: // 32 设置鼠标图标样式
|
2023-01-24 12:23:03 +08:00
|
|
|
|
m.cwcap.onSetCursor(message, lResult, aHandled)
|
2023-05-31 17:41:14 +08:00
|
|
|
|
case consts.WM_NCHITTEST: // 132 NCHITTEST
|
2023-01-24 12:23:03 +08:00
|
|
|
|
if m.cwcap.borderMD { //TODO 测试windows7, 161消息之后再次处理132消息导致消息错误
|
|
|
|
|
m.cwcap.borderMD = false
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
//鼠标坐标是否在标题区域
|
2023-06-10 19:22:06 +08:00
|
|
|
|
x, y, caption := m.cwcap.isCaption(et.HWND(m.Handle()), message)
|
2023-01-24 12:23:03 +08:00
|
|
|
|
if caption { //窗口标题栏
|
2023-05-31 17:41:14 +08:00
|
|
|
|
*lResult = consts.HTCAPTION
|
2023-01-24 12:23:03 +08:00
|
|
|
|
*aHandled = true
|
2023-02-12 17:28:31 +08:00
|
|
|
|
} else if m.WindowProperty().EnableHideCaption && m.WindowProperty().EnableResize && m.WindowState() == types.WsNormal { //1.窗口隐藏标题栏 2.启用了调整窗口大小 3.非最大化、最小化、全屏状态
|
2023-01-24 12:23:03 +08:00
|
|
|
|
rect := m.BoundsRect()
|
|
|
|
|
if result, handled := m.cwcap.onCanBorder(x, y, &rect); handled {
|
|
|
|
|
*lResult = types.LRESULT(result)
|
2023-01-18 18:41:36 +08:00
|
|
|
|
*aHandled = true
|
2023-01-18 08:37:08 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-20 00:20:01 +08:00
|
|
|
|
// setDraggableRegions
|
2023-02-12 17:28:31 +08:00
|
|
|
|
// 每一次拖拽区域改变都需要重新设置
|
2023-01-18 16:34:04 +08:00
|
|
|
|
func (m *LCLBrowserWindow) setDraggableRegions() {
|
2023-01-20 13:50:26 +08:00
|
|
|
|
//在主线程中运行
|
2023-01-20 13:22:00 +08:00
|
|
|
|
QueueAsyncCall(func(id int) {
|
|
|
|
|
if m.cwcap.rgn == nil {
|
2023-01-20 13:50:26 +08:00
|
|
|
|
//第一次时创建RGN
|
2023-06-11 00:10:55 +08:00
|
|
|
|
m.cwcap.rgn = winapi.WinCreateRectRgn(0, 0, 0, 0)
|
2023-01-20 13:22:00 +08:00
|
|
|
|
} else {
|
2023-01-20 13:50:26 +08:00
|
|
|
|
//每次重置RGN
|
2023-06-11 00:10:55 +08:00
|
|
|
|
winapi.WinSetRectRgn(m.cwcap.rgn, 0, 0, 0, 0)
|
2023-01-20 13:22:00 +08:00
|
|
|
|
}
|
|
|
|
|
for i := 0; i < m.cwcap.regions.RegionsCount(); i++ {
|
|
|
|
|
region := m.cwcap.regions.Region(i)
|
2023-06-11 00:10:55 +08:00
|
|
|
|
creRGN := winapi.WinCreateRectRgn(region.Bounds.X, region.Bounds.Y, region.Bounds.X+region.Bounds.Width, region.Bounds.Y+region.Bounds.Height)
|
2023-01-20 13:22:00 +08:00
|
|
|
|
if region.Draggable {
|
2023-06-11 00:10:55 +08:00
|
|
|
|
winapi.WinCombineRgn(m.cwcap.rgn, m.cwcap.rgn, creRGN, consts.RGN_OR)
|
2023-01-20 13:22:00 +08:00
|
|
|
|
} else {
|
2023-06-11 00:10:55 +08:00
|
|
|
|
winapi.WinCombineRgn(m.cwcap.rgn, m.cwcap.rgn, creRGN, consts.RGN_DIFF)
|
2023-01-20 13:22:00 +08:00
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
|
winapi.WinDeleteObject(creRGN)
|
2023-01-20 13:22:00 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
2023-01-18 16:34:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-20 00:20:01 +08:00
|
|
|
|
// registerWindowsCompMsgEvent
|
|
|
|
|
// 注册windows下CompMsg事件
|
2023-01-18 08:37:08 +08:00
|
|
|
|
func (m *LCLBrowserWindow) registerWindowsCompMsgEvent() {
|
|
|
|
|
var bwEvent = BrowserWindow.browserEvent
|
2023-05-31 17:41:14 +08:00
|
|
|
|
m.Chromium().SetOnRenderCompMsg(func(sender lcl.IObject, message *types.TMessage, lResult *types.LRESULT, aHandled *bool) {
|
2023-01-24 12:23:03 +08:00
|
|
|
|
if bwEvent.onRenderCompMsg != nil {
|
|
|
|
|
bwEvent.onRenderCompMsg(sender, message, lResult, aHandled)
|
|
|
|
|
}
|
|
|
|
|
if !*aHandled {
|
|
|
|
|
m.doOnRenderCompMsg(message, lResult, aHandled)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if m.WindowProperty().EnableWebkitAppRegion && m.WindowProperty().EnableWebkitAppRegionDClk {
|
2023-01-18 23:33:20 +08:00
|
|
|
|
m.windowResize = func(sender lcl.IObject) bool {
|
2023-02-12 17:28:31 +08:00
|
|
|
|
if m.WindowState() == types.WsMaximized && (m.WindowProperty().EnableHideCaption || m.BorderStyle() == types.BsNone || m.BorderStyle() == types.BsSingle) {
|
2023-01-18 23:33:20 +08:00
|
|
|
|
var monitor = m.Monitor().WorkareaRect()
|
|
|
|
|
m.SetBounds(monitor.Left, monitor.Top, monitor.Right-monitor.Left, monitor.Bottom-monitor.Top)
|
|
|
|
|
m.SetWindowState(types.WsMaximized)
|
2023-01-18 13:50:54 +08:00
|
|
|
|
}
|
2023-01-18 23:33:20 +08:00
|
|
|
|
return false
|
|
|
|
|
}
|
2023-01-18 08:37:08 +08:00
|
|
|
|
}
|
2023-01-24 12:23:03 +08:00
|
|
|
|
|
|
|
|
|
//if m.WindowProperty().EnableWebkitAppRegion {
|
|
|
|
|
//
|
|
|
|
|
//} else {
|
|
|
|
|
// if bwEvent.onRenderCompMsg != nil {
|
|
|
|
|
// m.chromium.SetOnRenderCompMsg(bwEvent.onRenderCompMsg)
|
|
|
|
|
// }
|
|
|
|
|
//}
|
2023-01-18 08:37:08 +08:00
|
|
|
|
}
|
2023-01-18 16:34:04 +08:00
|
|
|
|
|
2023-02-20 00:20:01 +08:00
|
|
|
|
// Maximize Windows平台,窗口最大化/还原
|
2023-01-18 16:34:04 +08:00
|
|
|
|
func (m *LCLBrowserWindow) Maximize() {
|
|
|
|
|
if m.TForm == nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
QueueAsyncCall(func(id int) {
|
|
|
|
|
win.ReleaseCapture()
|
2023-02-15 14:48:18 +08:00
|
|
|
|
m.windowProperty.windowState = m.WindowState()
|
|
|
|
|
if m.windowProperty.windowState == types.WsNormal {
|
2023-05-31 17:41:14 +08:00
|
|
|
|
rtl.PostMessage(m.Handle(), consts.WM_SYSCOMMAND, consts.SC_MAXIMIZE, 0)
|
2023-01-18 16:34:04 +08:00
|
|
|
|
} else {
|
2023-05-31 17:41:14 +08:00
|
|
|
|
rtl.SendMessage(m.Handle(), consts.WM_SYSCOMMAND, consts.SC_RESTORE, 0)
|
2023-01-18 16:34:04 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2023-01-23 18:17:22 +08:00
|
|
|
|
|
2023-02-20 00:20:01 +08:00
|
|
|
|
// 窗口透明
|
2023-01-23 21:17:33 +08:00
|
|
|
|
//func (m *LCLBrowserWindow) SetTransparentColor() {
|
|
|
|
|
// m.SetColor(colors.ClNavy)
|
|
|
|
|
// Exstyle := win.GetWindowLong(m.Handle(), win.GWL_EXSTYLE)
|
|
|
|
|
// Exstyle = Exstyle | win.WS_EX_LAYERED&^win.WS_EX_TRANSPARENT
|
|
|
|
|
// win.SetWindowLong(m.Handle(), win.GWL_EXSTYLE, uintptr(Exstyle))
|
|
|
|
|
// win.SetLayeredWindowAttributes(m.Handle(),
|
|
|
|
|
// colors.ClNavy, //crKey 指定需要透明的背景颜色值
|
|
|
|
|
// 255, //bAlpha 设置透明度,0完全透明,255不透明
|
|
|
|
|
// //LWA_ALPHA: crKey无效,bAlpha有效
|
|
|
|
|
// //LWA_COLORKEY: 窗体中的所有颜色为crKey的地方全透明,bAlpha无效
|
|
|
|
|
// //LWA_ALPHA | LWA_COLORKEY: crKey的地方全透明,其它地方根据bAlpha确定透明度
|
|
|
|
|
// win.LWA_ALPHA|win.LWA_COLORKEY)
|
|
|
|
|
//}
|