Windows-Taskbar App-Icon

Dear all,

https://documentation.xojo.com/index.php/Application.DockItem
on mac it works fine.
Is there a way on windows?
i would like to show a Icon that changes during the app-session, like Apple-Mail

Thanks,
Chrisstian

What do you want to do exact?
Set the window icon?

We have SetWindowIconMBS function for that in MBS Xojo Win Plugin:

Window.SetWindowIconMBS(Type as Integer, Icon as Picture, Mask as Picture) as Boolean

And for task bar, maybe you check our WindowsTaskbarListMBS and WindowsTaskbarStateMBS classes.

This probably isn’t always the case now with windows 10 but in windows the icon on the taskbar is usually the icon that is used for the window. See the demo in Examples>Platform-Specific>Windows>SetWindowIcon for an example of how to change it. Although that isn’t working in 64bit, I’ll take a look and see what’s wrong with it.

Replace the whole of SetIconButton.Action with this and it’ll work in 32 and 64bit:

[code]#If TargetWindows Then
#If Target64Bit
Soft Declare Function SetClassLong Lib “User32” Alias “SetClassLongPtrW” (hwnd As Integer, index As Integer, newLong As Integer) As Integer
#Else
Soft Declare Function SetClassLong Lib “User32” Alias “SetClassLongW” (hwnd As Integer, index As Integer, newLong As Integer) As Integer
#EndIf

Soft Declare Function ExtractIconW Lib “Shell32” (hinstance As Integer, absPath As WString, index As UInt32) As Integer
Declare Function GetModuleHandleW Lib “Kernel32” (path As WString) As Integer

// Get a handle to the current application’s HINSTANCE
Dim moduleHandle As Integer
moduleHandle = GetModuleHandleW(Nil)

// Now, extract a random icon from Shell32.dll
// (value -151 was chosen arbitrarily) and get a handle to it
Dim icon As Integer
icon = ExtractIconW(moduleHandle, SpecialFolder.System.Child(“Shell32.dll”).NativePath, -151)

If icon <> 0 Then
// Set the icon for the window only if we were
// able to pull an icon from the dll

// -14 is GCL_HICON
Call SetClassLong(Self.Handle, -14, icon)

End If
#EndIf[/code]

There’s also this that I wrote a while back, I think it should work though I’m on mobile so I can’t double check at the moment.

https://forum.xojo.com/47564-how-to-change-application-icon-dynamically/p1#p386335