From 8cd155e107ba4145ba8310b2b97e3435f03e6ecb Mon Sep 17 00:00:00 2001 From: yanghy Date: Thu, 20 Jul 2023 12:05:02 +0800 Subject: [PATCH] U: demo msgbox --- example/msgbox/msgbox.go | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/example/msgbox/msgbox.go b/example/msgbox/msgbox.go index 9177cf9..52bfc57 100644 --- a/example/msgbox/msgbox.go +++ b/example/msgbox/msgbox.go @@ -45,24 +45,22 @@ func main() { // 系统消息提示框目前仅能在LCL窗口组件下使用 // LCL 各种系统组件需要在UI线程中执行, 但ipc.on非UI线程 // 所以需要使用 QueueAsyncCall 包裹在UI线程中执行 - if window.IsLCL() { - ipc.On("showmsgbox", func() { - cef.QueueAsyncCall(func(id int) { - lcl.ShowMessage("消息提示框") - }) + ipc.On("showmsgbox", func() { + fmt.Println("showmsgbox") + window.RunOnMainThread(func() { + fmt.Println("消息提示框") + lcl.ShowMessage("消息提示框") }) - ipc.On("showmsgbox-confirm", func() { - // lcl 各种系统组件需要在UI线程中执行, 但ipc.on非UI线程 - // 所以需要使用 QueueAsyncCall 包裹在UI线程中执行 - cef.QueueAsyncCall(func(id int) { - if lcl.Application.MessageBox("消息", "标题", win.MB_OKCANCEL+win.MB_ICONINFORMATION) == types.IdOK { - lcl.ShowMessage("你点击了“是") - } - }) + }) + ipc.On("showmsgbox-confirm", func() { + // lcl 各种系统组件需要在UI线程中执行, 但ipc.on非UI线程 + // 所以需要使用 QueueAsyncCall 包裹在UI线程中执行 + window.RunOnMainThread(func() { + if lcl.Application.MessageBox("消息", "标题", win.MB_OKCANCEL+win.MB_ICONINFORMATION) == types.IdOK { + lcl.ShowMessage("你点击了“是") + } }) - // 使用窗口模拟一个消息提示框 - - } + }) }) //运行应用 -- GitLab