Closed shnmng closed 10 years ago
I believe this is not possible at the moment, unfortunately. But it would probably work if you added a new function to the walk package. Looking at the code of walk.NewIconFromResource(), I see it calls win.LoadIcon. Documentation for the WinAPI function on MSDN states:
lpIconName -- The name of the icon resource to be loaded. Alternatively, this parameter can contain the resource identifier in the low-order word and zero in the high-order word. [emphasis mine]
So, you could try and copy NewIconFromResource with slight modification to something like this:
package walk
func NewIconFromResourceId(id uint16) (ic *Icon, err error) {
hInst := win.GetModuleHandle(nil)
if hInst == 0 {
err = lastError("GetModuleHandle")
return
}
if hIcon := win.LoadIcon(hInst, (*uint16)(unsafe.Pointer(uintptr(id)))); hIcon == 0 {
err = lastError("LoadIcon")
} else {
ic = &Icon{hIcon: hIcon}
}
return
}
Then, you could open your binary file with some resource editor and find out what is ID of the icon (or just try a few small numbers, between 0 and 3, as the IDs are created sequentially by rsrc). The rsrc tool could help with that part if it printed IDs of resources it creates; if you'd care enough to try and add this feature to the code, I'd be very grateful if you let me merge it.
I'm not sure if it will work, sorry; unfortunately, I don't have much time now to explore this question more deeply. Hope this helps you somewhat!
Mateusz, thanks for taking the time to help with this!
2 steps needed for setting the same application Icon also on all GUI windows
var appIcon, _ = walk.NewIconFromResourceId(3) // number 3 is resource ID printed by RSRC.exe while making .syso file
MainWindow{
Title: "YourApplication",
Name: "MainWindow",
AssignTo: &mainWindow,
Icon: appIcon,
MinSize: Size{600, 400},
Size: Size{1024, 640},
Layout: HBox{MarginsZero: true},
...
You can also do it like this: Icon: 3,
or Icon: "foo",
.
I want to know when i embed a icon to *.syso file , when i use it on walk ,like this walk.NewIconFromResource("xxx") what is the xxx ?