Icon for AddIn

D

Dave Mc

Hi,

I've created an Addin for OneNote following the guidelines in 'How to Create
a OneNote Toolbar Addin' (a very useful article - thanks to Daniel Escapa)
and have it running (almost) happily (see a subsequent question). I've
inferred, perhaps wrongly, that it's possible for the button that calls the
AddIn to have an icon, rather than just plain text, by using the IconPath and
IconIndex registry keys added to the HKCU/////{GUID} list.

Using those two registry values, I've tried pointing at an icon file. I
first added the existing .ico file into the AddIn project, then added the
simple .ico filename into the ApplicationFolder list of the setup project. I
also set the two registry key values I indicated above: for Icon Path, I used
the simple .ico file name; for IconIndex, I used '0'. I've tried several
alternatives in trying to make this work, even removing the 'ButtonText'
parameter, but to no avail. By the way, I don't get any build or
installation errors when trying this.

I scanned the source of a couple of PowerToy projects available on the web,
but they don't appear to even use the Registry construct, let alone the
IconPath/IconIndex parameters.

Can someone advise whether what I'm trying to do is even possible, please?
If it is, can you give some pointers as to where I might be going wrong?


TIA

DaveMc
 
R

Rainald Taesler

John said:
16x16 BMP is what I use.

Yes, that's what I use following your recipe.

BTW: The re-read of your blog-article produced a good smile.
You named me "one of OneNote's MVPs". This for sure honors me. But I'm
no "MVP". :-( :-(
Could be "MFT" (most frequent poster) <g>

Regards
Rainald
 
D

Dave Mc

Rainald, John,

Thanks for your replies.

I've done some experimentation along the lines you described and have had
some success with creating an icon for my addin. I even managed to make a
16x32 icon, so it appears we're not limited to just 16x16. I was only
successful with .bmp files, though, and have not been able to use .ico files,
even using the IconIndex key.

The VS Setup project that I'm using modifies the registry keys to notify
OneNote that the AddIn exists and to provide the path for the Icon. I
include the icon file in the setup project and get it installed in the
Application Folder, as required. This all works fine. When doing this, I've
used an absolute filepath for the IconPath key ie I've had to predict where
the .bmp file would be placed when it's installed, even though the user has
the choice of changing this during installation. Within the SetUp project,
is there a way to set the IconPath registry key to the correct value if the
user chooses a different installation path during the installation process?

DaveMc
 
J

John Guin [msft]

Yes - use the [TARGETDIR] env. variable in the regkey path.

For instance, set the IconPath value to [TARGETDIR]toolbar_icon.bmp
(assuming your icon is named toobar_icon.bmp). Notice you do not need the
trailing slash after the closing bracket.
 
R

Rainald Taesler

Thanks for the success report.

Rainald

Dave said:
Rainald, John,

Thanks for your replies.

I've done some experimentation along the lines you described and have
had some success with creating an icon for my addin. I even managed
to make a 16x32 icon, so it appears we're not limited to just 16x16.
I was only successful with .bmp files, though, and have not been able
to use .ico files, even using the IconIndex key.

The VS Setup project that I'm using modifies the registry keys to
notify OneNote that the AddIn exists and to provide the path for the
Icon. I include the icon file in the setup project and get it
installed in the Application Folder, as required. This all works
fine. When doing this, I've used an absolute filepath for the
IconPath key ie I've had to predict where the .bmp file would be
placed when it's installed, even though the user has the choice of
changing this during installation. Within the SetUp project, is
there a way to set the IconPath registry key to the correct value if
the user chooses a different installation path during the
installation process?

DaveMc
 
D

Dave Mc

John, Rainald,

I've achieved the desired result - I now have an icon that is installed in
the target ApplicationFolder uaing the [TARGETDIR] construct. Thanks for the
help on that.

By the way, I've found it's possible to use larger icons than 16x16, though
it seems they must be square. I've successfully used 256x256. I've still
only succeeded with .BMP files. Is there any way to use .ICO? Is that what
the 'IconIndex' key is for, by any chance?

DaveMc
 
R

Rainald Taesler

Thanks for the feedback.
As said before this issue is above my head :-( :-(

Rainald
 
J

John Guin [msft]

If you build a resource file in your project, the IconIndex should retrieve
the indexed resource from that file.
 
D

Dave Mc

John,

Thanks, once again, for this info. Maybe I'll try that another time. Now I
can use the .bmp icon satisfactorily, so my objective is achieved.

Thanks for all your help.

DaveMc

John Guin said:
If you build a resource file in your project, the IconIndex should retrieve
the indexed resource from that file.

--
Thanks,
John Guin
OneNote Test Team
http://blogs.msdn.com/johnguin


Dave Mc said:
John, Rainald,

I've achieved the desired result - I now have an icon that is installed in
the target ApplicationFolder uaing the [TARGETDIR] construct. Thanks for the
help on that.

By the way, I've found it's possible to use larger icons than 16x16, though
it seems they must be square. I've successfully used 256x256. I've still
only succeeded with .BMP files. Is there any way to use .ICO? Is that what
the 'IconIndex' key is for, by any chance?

DaveMc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top