MsoButtonStyle.msoButtonIconAndCaption

Y

Yael

My problem is that I don't see my icon bmp in a butoon add-in :
In my work computer this code working good and I see the add-in button in
outlook,
I was created new project (same code but guid else), in my home computer and
I can't see the icon..
this.toolbarBtn2.Style = MsoButtonStyle.msoButtonIconAndCaption;
// set pic to this button2
string ns = this.GetType().Namespace;
Assembly CurrentAssembly = this.GetType().Assembly;
System.IO.Stream imgStreamPic =
CurrentAssembly.GetManifestResourceStream(ns+"." + "matarotqm.bmp");
stdole.IPictureDisp Pic =
MatarotHost.IPictureDisp(Image.FromStream(imgStreamPic));
this.toolbarBtn2.Picture = Pic;

using System;
using System.Drawing;
using System.Windows.Forms;
using stdole;

namespace MatarotToolbar
{
/// <summary>
/// Summary description for MatarotHost.
/// </summary>
public class MatarotHost : AxHost
{
public MatarotHost() : base( "3E9806D0-18A4-47EA-98A0-69C71BEC2AD9"){ }
public static stdole.IPictureDisp IPictureDisp(System.Drawing.Image Image)
{
return ((stdole.IPictureDisp)(AxHost.GetIPictureDispFromPicture(Image)));
}
}

}
 
K

Ken Slovak - [MVP - Outlook]

Can you step the code or write error logging to see what's failing on the
target computer? It's hard to say why it's working on one computer and not
the other from this information. Is the image where it should be on the
target system?
 
Y

Yael

This is my code, (in the prev post), I don't get error, but All the code
under these line (set the icon), ignored..I didn't know why, so I get the
poit that my problem is after the icon settings.
 
K

Ken Slovak - [MVP - Outlook]

I saw the code and it looked OK. It's similar to what I use, although I
don't use a stream.

I use something like this:

System.Drawing.Image imgPic;
IPictureDisp oPic = null;
MyAxHost ax = new MyAxHost();
imgPic = addin.Properties.Resources.myImage; //VS 2005
oPic = ax.PictureDispFromImage(imgPic);
_button.Picture = oPic;

My AxHost code is almost identical to yours except I use a different GUID.

That's why I suggested stepping the code and checking what you're getting at
each step, the code you have looks OK. So there's no way to just look at it
and say "aha, that's the reason".

Is your button image a BMP using 8-bit color (256 colors) in 16x16 pixel
format?
 
Y

Yael

I fixed my problem by setting icon properties:
Build Action = Embedded Resource!!!
Thank's anyway...
Yael
 

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

Similar Threads


Top