~eliasnaur/gio

1

How set up windows icon in the app title bar?

Details
Message ID
<AM9PR01MB8315BE7BB59D28B6E42A9C37E3AAA@AM9PR01MB8315.eurprd01.prod.exchangelabs.com>
DKIM signature
missing
Download raw message
I need to set the icon in the window title bar for windows. I can’t find any way.
I see there is a code that loads an icon from resources, but I am not sure if it’s the window icon, and I can’t understand how to set it.

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
}


The res uint32 seems to be set to be set to 1 and I can’t understand how to load it.

In my application I am setting resources with https://github.com/tc-hib/go-winres , I have setup correctly the app icon and system bar icon with that, but I can’t find any way to set window title icon.

I think the best would be to have an option like app.NewWindow(app.Title("Title"), app.Icon(“ICON”))  so it can be set at runtime, but for now it’s okay to set an icon in resources at compile time.

I have also asked on stackoverflow: https://stackoverflow.com/questions/77431771/how-setup-a-title-bar-icon-with-gio 

There is a way to do it?

Thank you,
Stefano.
Details
Message ID
<CAFcc3FR9A9=sxS62XKGnga6Z1zkJE7NQKAcyapPTiPSuxJ_6Sw@mail.gmail.com>
In-Reply-To
<AM9PR01MB8315BE7BB59D28B6E42A9C37E3AAA@AM9PR01MB8315.eurprd01.prod.exchangelabs.com> (view parent)
DKIM signature
missing
Download raw message
On Mon, Nov 6, 2023 at 1:24 PM Stefano Balzarotti
<stefano.balzarotti@orbintsoft.net> wrote:
>
> I need to set the icon in the window title bar for windows. I can’t find any way.
> I see there is a code that loads an icon from resources, but I am not sure if it’s the window icon, and I can’t understand how to set it.
>
> 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
> }
>
>
> The res uint32 seems to be set to be set to 1 and I can’t understand how to load it.
>
> In my application I am setting resources with https://github.com/tc-hib/go-winres , I have setup correctly the app icon and system bar icon with that, but I can’t find any way to set window title icon.
>
> I think the best would be to have an option like app.NewWindow(app.Title("Title"), app.Icon(“ICON”))  so it can be set at runtime, but for now it’s okay to set an icon in resources at compile time.
>
> I have also asked on stackoverflow: https://stackoverflow.com/questions/77431771/how-setup-a-title-bar-icon-with-gio

I'm glad to see that you've found an answer on your SO question. This
is certainly something we could do better. I'm not sure that an app
option is the proper way to proceed, as this seems like it's more of a
packaging problem. Perhaps we need to expand gogio to be more flexible
about this? Or is there a reason that I'm overlooking that an
app.Option makes more sense?

Cheers,
Chris
Reply to thread Export thread (mbox)