增加一些功能函数

This commit is contained in:
杨红岩 2022-10-26 16:25:59 +08:00
parent 7956caf7d6
commit ccfda4b034
3 changed files with 58 additions and 9 deletions

View File

@ -23,7 +23,7 @@ var (
//3. 该窗口是主窗体,因此初始化时必须第一个初始化完成,如果创建子窗口最好在 SetBrowserInitAfter 回调函数中创建
//你也可以在 SetBrowserInit 回调函数初始化时创建子窗口,但是不能在主窗体显示之前显示子窗口. 尤其是带有chromium的窗口.
BrowserWindow = &browser{
browserWindow: &browserWindowForm{},
browserWindow: &browserWindow{},
browserEvent: &BrowserEvent{},
Config: &browserConfig{},
windowInfo: make(map[int32]*TCefWindowInfo),
@ -34,7 +34,7 @@ var (
// 浏览器包装结构体
type browser struct {
browserWindow *browserWindowForm //主窗口
browserWindow *browserWindow //主窗口
popupWindow *BaseWindow //弹出的子窗口
browserEvent *BrowserEvent //浏览器全局事件
Config *browserConfig //浏览器和窗口配置
@ -76,7 +76,7 @@ type BrowserEvent struct {
onBeforeContextMenu ChromiumEventOnBeforeContextMenu //default
}
type browserWindowForm struct {
type browserWindow struct {
BaseWindow
isFirstActivate bool
tray ITray
@ -100,7 +100,7 @@ func Run(cefApp *TCEFApplication) {
}
}
func (m *browserWindowForm) OnFormCreate(sender lcl.IObject) {
func (m *browserWindow) OnFormCreate(sender lcl.IObject) {
if BrowserWindow.Config.chromiumConfig == nil {
BrowserWindow.Config.chromiumConfig = NewChromiumConfig()
BrowserWindow.Config.chromiumConfig.SetEnableMenu(true)

View File

@ -140,6 +140,60 @@ func (m *TCefWindowInfo) Close() {
})
}
//禁用口透明
func (m *TCefWindowInfo) DisableTransparent() {
m.Window.SetAllowDropFiles(false)
m.Window.SetAlphaBlend(false)
m.Window.SetAlphaBlendValue(255)
}
//使窗口透明 value 0 ~ 255
func (m *TCefWindowInfo) EnableTransparent(value uint8) {
m.Window.SetAllowDropFiles(true)
m.Window.SetAlphaBlend(true)
m.Window.SetAlphaBlendValue(value)
}
//禁用最小化按钮
func (m *TCefWindowInfo) DisableMinimize() {
m.Window.SetBorderIcons(m.Window.BorderIcons().Exclude(types.BiMinimize))
}
//禁用最大化按钮
func (m *TCefWindowInfo) DisableMaximize() {
m.Window.SetBorderIcons(m.Window.BorderIcons().Exclude(types.BiMaximize))
}
//禁用系统菜单-同时禁用最小化,最大化,关闭按钮
func (m *TCefWindowInfo) DisableSystemMenu() {
m.Window.SetBorderIcons(m.Window.BorderIcons().Exclude(types.BiSystemMenu))
}
//禁用帮助菜单
func (m *TCefWindowInfo) DisableHelp() {
m.Window.SetBorderIcons(m.Window.BorderIcons().Exclude(types.BiHelp))
}
//启用最小化按钮
func (m *TCefWindowInfo) EnableMinimize() {
m.Window.SetBorderIcons(m.Window.BorderIcons().Include(types.BiMinimize))
}
//启用最大化按钮
func (m *TCefWindowInfo) EnableMaximize() {
m.Window.SetBorderIcons(m.Window.BorderIcons().Include(types.BiMaximize))
}
//启用系统菜单-同时禁用最小化,最大化,关闭按钮
func (m *TCefWindowInfo) EnableSystemMenu() {
m.Window.SetBorderIcons(m.Window.BorderIcons().Include(types.BiSystemMenu))
}
//启用帮助菜单
func (m *TCefWindowInfo) EnableHelp() {
m.Window.SetBorderIcons(m.Window.BorderIcons().Include(types.BiHelp))
}
// 设置或增加一个窗口序号
func (m *browser) setOrIncNextWindowNum(browserId ...int32) int32 {
if len(browserId) > 0 {

View File

@ -169,17 +169,12 @@
}
function divMnmousedown(e) {
document.getElementById("test").innerHTML = "";
test("onmousedown client:", e.clientX, e.clientY);
//ipc.emit("windowMouseDown",[e.clientX,e.clientY]);
windowDrag.mousedown(e.clientX, e.clientY);
document.onmousemove = function (e) {
e.preventDefault()
windowDrag.mousemove(e.clientX, e.clientY);
//ipc.emit("windowMouseMove",[e.clientX,e.clientY]);
}
document.onmouseup = function () {
//ipc.emit("windowMouseUp");
windowDrag.mouseup();
document.onmousemove = null;
document.onmouseup = null;