forked from go/golangs_learn
VIVIMAN
2 years ago
4 changed files with 46 additions and 11 deletions
Binary file not shown.
Binary file not shown.
@ -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() |
||||
|
} |
Loading…
Reference in new issue