Gio UI(https://gioui.org/)有问题。
的数据
正如你看到的,窗口图标没有设置,也没有设置它的选项。
创建新窗口时,只能设置标题:
w := app.NewWindow(app.Title("My APP Title"))
字符串
但是如果我理解正确的话,图标应该从资源清单中加载:
go\pkg\mod\[email protected]\app\internal\windows\windows.go
型
//
func LoadImage(hInst syscall.Handle, res uint32, typ uint32, cx, cy int, fuload uint32) (syscall.Handle, error) {
h, _, err := _LoadImage.Call(uintptr(hInst), uintptr(res), uintptr(typ), uintptr(cx), uintptr(cy), uintptr(fuload))
if h == 0 {
return 0, fmt.Errorf("LoadImageW failed: %v", err)
}
return syscall.Handle(h), nil
}
型
要构建资源清单,我使用go winres:https://github.com/tc-hib/go-winres
我已经在winres.json中正确设置了应用程序图标和指南中解释的图标。
我认为应该有一种方法来设置应用程序标题中的窗口图标,但我找不到我应该在json中指定哪个键:
{
"RT_GROUP_ICON": {
"APP": {
"0000": [
"icon_64.png",
"icon_48.png",
"icon_32.png",
"icon_16.png"
]
},
"OTHER": {
"0000": "icon.png"
},
"#42": {
"0409": "icon_EN.ico",
"040C": "icon_FR.ico"
}
}
}
型
1条答案
按热度按时间nkhmeac61#
官方的方法是使用gogio工具,不幸的是,它的文档非常糟糕,与go-winres相比有很多限制。
使用
go install gioui.org/cmd/gogio@latest
安装然后使用以下命令编译应用程序:
字符串
根据您的需求更改架构和路径。
无论如何,据我所知,gogio只支持png,它会自动生成所有需要的决议。
由于我想使用go-winres,我刚刚使用Resource Hacker来反编译exe资源。
我发现要设置图标,你需要像这样设置winres.json:
型
然后你就可以用go build和go-winres正常编译了,只需要记住设置
-ldflags=-H=windowsgui