5

I am using a WPF JumpTask object, and I would like my Windows 7 jumplist icon to be an icon from my own application - but not the default one. A different one.

So how do I do this? I guess I specify a different icon resource index.

But how do I even store my icons as resources, and how do I know which icon is which index?

Mathias Lykkegaard Lorenzen
  • 15,031
  • 23
  • 100
  • 187

2 Answers2

2

According to MSDN

An icon used with a JumpTask must be available as a native resource.

you can only load icons from separate resource file. So, you need to set IconResourcePath property to DLL with your icons. If you have few icons, use IconResourceIndex property to specify needed one.

For example, next code

<Application x:Class="YourApp.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
    <JumpList.JumpList>
        <JumpList>
            <JumpTask Title="TargetApp"
                      Description="JumpTask to start TargetApp"
                      ApplicationPath="TargetApp.exe"
                      IconResourcePath="LibWithIcons.dll"
                      IconResourceIndex="2" />
        </JumpList>
    </JumpList.JumpList>
</Application>

will create JumpList and set to JumpTask item TargetApp third icon (null-based numeration) from LibWithIcons.dll. By the way, if JumpTask starts another application usually IconResourcePath is set to the executable file of that application, so it icon will be displayed:

<JumpTask Title="TargetApp"
    Description="JumpTask to start TargetApp"
    ApplicationPath="TargetApp.exe"
    IconResourcePath="TargetApp.exe"
    IconResourceIndex="0" />

How to create icons DLL described on MSDN forums.

kyrylomyr
  • 12,192
  • 8
  • 52
  • 79
  • 2
    How do you know which icon is at which index? Your answer doesn't make this clear. – imoatama Oct 07 '12 at 18:50
  • 1
    How do you add icons and/or know what index it is? The answer is not clear, and neither is the link. It says how to add icons, but none of them appear in any index I attempt from 0 to 50. – user99999991 Sep 17 '15 at 20:01
1

It's looking for your icons in a Win32 resource, which is quite different to a managed resource. Take a look at this excellent write-up to understand these - it is possible to create them and specify icon order.

Embed Icons into WPF Application as Resource

I ended up using a great tool created by Einar Eigilson which allows you to add the icons as a resource in a post-build event.

It's also worth noting that I could't get the icons to display when running in Debug mode, regardless of what I did. Even embedding a static win32 resource didn't show any of the icons beyond the main icon. Try testing in Release before you pull your hair out like I did.

Community
  • 1
  • 1
imoatama
  • 933
  • 6
  • 13
  • You can get the main window icon to display while running in the debugger by assigning it directly to the main window's Icon property somewhere like in the window's constructor after InitializeComponent(). The following works, though it gets you the wrong icon size. `Icon = Imaging.CreateBitmapSourceFromHIcon(KillXDes.Properties.Resources.KillProcIcon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());` Not an important issue, but they screwed it up royally. – 15ee8f99-57ff-4f92-890c-b56153 Dec 22 '15 at 16:53