diff --git a/golang_learn/data_func/go_to_xcgui/main02/demo.zip b/golang_learn/data_func/go_to_xcgui/main02/demo.zip deleted file mode 100644 index 506f2e8..0000000 Binary files a/golang_learn/data_func/go_to_xcgui/main02/demo.zip and /dev/null differ diff --git a/golang_learn/data_func/go_to_xcgui/main02/main.go b/golang_learn/data_func/go_to_xcgui/main02/main.go index f3b91bf..5ee0782 100644 --- a/golang_learn/data_func/go_to_xcgui/main02/main.go +++ b/golang_learn/data_func/go_to_xcgui/main02/main.go @@ -5,24 +5,19 @@ import ( "github.com/twgh/xcgui/app" "github.com/twgh/xcgui/widget" "github.com/twgh/xcgui/window" - "github.com/twgh/xcgui/xc" ) // TODO 失败 -//go:embed XCGUI.dll -var dll []byte - -//go:embed demo.zip -var zip []byte - func main() { - // 把 xcgui.dll 写出到windows临时目录 - _ = xc.WriteDll(dll) a := app.New(true) - // 创建窗口从内存压缩包中的布局文件 - w := window.NewByLayoutZipMem(zip, "main.xml", "123456", 0, 0) + // 添加文件搜索路径, 因为main.xml没有在程序运行目录 + a.AddFileSearchPath(`D:\XcCodes\demo`) + // 创建窗口从布局文件 + w := window.NewByLayout("main.xml", 0, 0) // 获取窗口布局文件中的按钮 + // btn := widget.NewButtonByHandle(1000) + // btn := widget.NewButtonByUID(1000) btn := widget.NewButtonByName("viviman") // 注册按钮被单击事件 btn.Event_BnClick(func(pbHandled *bool) int { diff --git a/golang_learn/data_func/go_to_xcgui/main03/demo.zip b/golang_learn/data_func/go_to_xcgui/main03/demo.zip new file mode 100644 index 0000000..654c43a Binary files /dev/null and b/golang_learn/data_func/go_to_xcgui/main03/demo.zip differ diff --git a/golang_learn/data_func/go_to_xcgui/main03/main.go b/golang_learn/data_func/go_to_xcgui/main03/main.go new file mode 100644 index 0000000..b7f4e45 --- /dev/null +++ b/golang_learn/data_func/go_to_xcgui/main03/main.go @@ -0,0 +1,40 @@ +package main + +import ( + _ "embed" + "github.com/twgh/xcgui/app" + "github.com/twgh/xcgui/widget" + "github.com/twgh/xcgui/window" + "github.com/twgh/xcgui/xc" +) + +// TODO 失败 +//go:embed XCGUI.dll +var dll []byte + +//go:embed demo.zip +var zip []byte + +func main() { + // 把 xcgui.dll 写出到windows临时目录 + _ = xc.WriteDll(dll) + a := app.New(true) + // 创建窗口从内存压缩包中的布局文件 + w := window.NewByLayoutZipMem(zip, "main.xml", "123456", 0, 0) + + // 获取窗口布局文件中的按钮 + btn := widget.NewButtonByUID(0) + // btn := widget.NewButtonByName("viviman") + // 注册按钮被单击事件 + btn.Event_BnClick(func(pbHandled *bool) int { + a.Alert("提示", btn.GetText()+"被点击") + return 0 + }) + + // 调整布局, 必须 + w.AdjustLayout() + // 显示窗口 + w.Show(true) + a.Run() + a.Exit() +}