Strange behaviour picture and mask properties

E

Erkan Ozkurt

Hi,

I catch new inspector event and for new mail and new appointment
inspectors I add some commandbarbutton. My problem occurs when I try to
seet picture and mask properties of these buttons. When I try to set
picture and mask property of my button in new mail inspector I get
catastrophic failure while I get no error when I try to set picture and
mask properties of my button in new appointment inspector. Can you
suggest me something that I can prevent this strange behaviour?

My code is:


try
{
//Here check whether it is a mail item
MailItem mi=(MailItem)newInspector.CurrentItem;
passed=true;
//if found delete previous button
try
{
this.sendSMSButton=(CommandBarButton)Inspector.CommandBars["Standard"].Controls["SMS"];
this.sendSMSButton.Delete(System.Reflection.Missing.Value);
}
catch(System.Exception exp){

}
//Now create the new button
this.sendSMSButton=(CommandBarButton)newInspector.CommandBars["Standard"].Controls.Add(MsoControlType.msoControlButton,
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value,true);
this.sendSMSButton.Caption="SMS";
this.sendSMSButton.Click += new
_CommandBarButtonEvents_ClickEventHandler(this.sendWithSMS);
this.sendSMSButton.Style = MsoButtonStyle.msoButtonIconAndCaption;
this.sendSMSButton.Tag = "bt1"+(mytag++);
this.sendSMSButton.OnAction = "!<outlookPlugin.Connect>";
//Here I set picture and mask property and get catastrophic failure
exception
showicon(ref this.sendSMSButton);
this.sendSMSButton.Visible = true;
}
catch(System.Exception exp){
}
if(!passed){
try{
//Check whether it is an appointment item
reminderAppointment=false;
MessageBox.Show("Ai item?");
AppointmentItem ai=(AppointmentItem)newInspector.CurrentItem;
MessageBox.Show("ai item");
passed=true;
//Find previous button and delete it
try
{
this.reminderAsSMSAppointment=(CommandBarButton)newInspector.CommandBars["Standart"].Controls["Reminder
As SMS"];
this.reminderAsSMSAppointment.Delete(System.Reflection.Missing.Value);
}
//Create new button
catch
{}
this.reminderAsSMSAppointment=(CommandBarButton)newInspector.CommandBars["Standard"].Controls.Add(MsoControlType.msoControlButton,
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value,true);
this.reminderAsSMSAppointment.Caption="Reminder As SMS";
this.reminderAsSMSAppointment.Click += new
_CommandBarButtonEvents_ClickEventHandler(this.reminderToSMSAppointment);
this.reminderAsSMSAppointment.Style =
MsoButtonStyle.msoButtonIconAndCaption;
this.reminderAsSMSAppointment.Tag = "bt2"+(mytag++);
this.reminderAsSMSAppointment.OnAction =
"!<outlookPlugin.Connect>";
//Here I set picture successfully
showicon(ref this.reminderAsSMSAppointment);
this.reminderAsSMSAppointment.Visible=true;
}
catch(System.Exception exp)
{
MessageBox.Show(exp.Message+exp.StackTrace);
}
}


//This sets icons
private void showicon(ref CommandBarButton btn)
{
try
{
btn.Picture =
(IPictureDisp)AxHost2.GetIPictureDispFromPicture(Image.FromFile("c:\\clicked.bmp"));
btn.Mask =
(IPictureDisp)AxHost2.GetIPictureDispFromPicture(Image.FromFile("c:\\mask.bmp"));
}
catch(System.Exception exp)
{
MessageBox.Show(exp.Message+exp.StackTrace);
}
}
 
E

Erkan ?ZKURT

I found an aswer to my own question. Picture and mask properties can
be correctly if new mail inspector is not word editor. My problem was
that my default mail editor was word and when I change this option
problem disappeard. So why I can not set picture property in word
editor or if there is a way how can I set an icon for my commandbar?
 

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