Skip to content

Commit

Permalink
U: Adjust the timing of the main window settings
Browse files Browse the repository at this point in the history
  • Loading branch information
sxmxta committed Apr 7, 2024
1 parent 0c330a3 commit f934ef7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions cef/browser_main_window.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func (m *browserWindow) createFormAndRun() {
if m.Config.EnableMainWindow {
// 使用主窗口创建
lcl.Application.CreateForm(&enableMainWindow, true)
BrowserWindow.mainBrowserWindow = enableMainWindow
} else {
// 使用禁用窗口创建, 它默认不会显示, 在它的 OnFormCreate 中创建主窗口
lcl.Application.CreateForm(&disabledMainWindow, true)
Expand All @@ -88,7 +87,6 @@ func (m *browserWindow) createFormAndRun() {
func (m *disableMainWindow) OnFormCreate(sender lcl.IObject) {
// 禁用主窗口后需要创建一个新的窗口来代替主窗口显示
lcl.Application.CreateForm(&enableMainWindow, true)
BrowserWindow.mainBrowserWindow = enableMainWindow
// 显示窗口,此时的主窗口是默认显示的第一个窗口, 如果将该主窗口关闭,在获取主窗口函数将返回无效的窗口
BrowserWindow.MainWindow().Show()
}
Expand All @@ -104,6 +102,7 @@ func (m *lclBrowserWindow) OnFormCreate(sender lcl.IObject) {
m.defaultChromiumEvent()
m.SetProperty()
m.SetShowInTaskBar()
BrowserWindow.mainBrowserWindow = m
if BrowserWindow.Config.browserWindowOnEventCallback != nil {
BrowserWindow.browserEvent.chromium = m.Chromium()
BrowserWindow.Config.browserWindowOnEventCallback(BrowserWindow.browserEvent, m)
Expand Down
4 changes: 2 additions & 2 deletions cef/browser_window_lcl.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ func NewLCLBrowserWindow(config *TCefChromiumConfig, windowProperty WindowProper
// owner: 被创建组件拥有者
func NewLCLWindow(windowProperty WindowProperty, owner lcl.IComponent) *LCLBrowserWindow {
var window *LCLBrowserWindow
//lcl.Application.CreateForm(&window)
//lcl.Application.CreateForm(&window) // create 1
window = new(LCLBrowserWindow)
window.TForm = lcl.NewForm(owner)
window.TForm = lcl.NewForm(owner) // create 2
// 窗口设置一个名字
window.TForm.SetName(fmt.Sprintf("Form_%d", time.Now().UnixNano()/1e6))
window.windowProperty = &windowProperty
Expand Down
2 changes: 1 addition & 1 deletion cef/chromium_browser_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (m *TCEFChromiumBrowser) registerWindowsCompMsgEvent() {
if bwEvent.onRenderCompMsg != nil {
bwEvent.onRenderCompMsg(sender, message, lResult, aHandled)
}
if !*aHandled {
if !*aHandled && window.cwcap != nil {
window.doOnRenderCompMsg(m, cmtCEF, message, lResult, aHandled)
}
})
Expand Down

0 comments on commit f934ef7

Please sign in to comment.