Z
Zeus
I am starting an Add-In which so far just modifies the Context menu. It will
do it one way for an email and another for a task. When right click on an
email in the Inbox viewer pane it works great. If I look at the email on my
To-Do bar then, my custom button has been doubled, also if I look at a task
in the To-Do Bar my entires for that get doubled as well.
Here is my ItemContextMenuDisplay handler:
try
{
mail = Selection[1] as Outlook.MailItem;
task = Selection[1] as Outlook.TaskItem;
if (mail != null && task == null)
{
newTaskButton =
CommandBar.Controls.Add(Microsoft.Office.Core.MsoControlType.msoControlButton, missing, missing, missing, true) as Microsoft.Office.Core.CommandBarButton;
newTaskButton.Visible = true;
newTaskButton.Caption = createNewTaskPrompt;
newTaskButton.Click += ConvertMailToTaskAction;
}
else if (task != null && mail == null)
{
startWorkButton =
CommandBar.Controls.Add(Microsoft.Office.Core.MsoControlType.msoControlButton, missing, missing, missing, true) as Microsoft.Office.Core.CommandBarButton;
startWorkButton.Visible = true;
startWorkButton.Caption = startWorkingPrompt;
startWorkButton.Click += startTimerAction;
stopWorkButton =
CommandBar.Controls.Add(Microsoft.Office.Core.MsoControlType.msoControlButton, missing, missing, missing, true) as Microsoft.Office.Core.CommandBarButton;
stopWorkButton.Visible = true;
stopWorkButton.Caption = stopWorkingPrompt;
stopWorkButton.Click += stopTimerAction;
}
}
and Here is my COntextMenuClose handler:
try
{
if (newTaskButton != null)
{
newTaskButton.Click -= ConvertMailToTaskAction;
newTaskButton = null;
}
if (startWorkButton != null)
{
startWorkButton.Click -= startTimerAction;
startWorkButton = null;
}
if (stopWorkButton != null)
{
stopWorkButton.Click -= stopTimerAction;
stopWorkButton = null;
}
mail = null;
task = null;
}
The same code is behaving different and it just has me baffled. I thought
maybe it was getting run twice and made all sorts of logic to check for its
existence and stuff but nothing has prevent duplicates on my to-do bar.
Can anyone see anything I am doing wrong? Or explain the different behavior
between the to-do bar and inbox viewer pane.
do it one way for an email and another for a task. When right click on an
email in the Inbox viewer pane it works great. If I look at the email on my
To-Do bar then, my custom button has been doubled, also if I look at a task
in the To-Do Bar my entires for that get doubled as well.
Here is my ItemContextMenuDisplay handler:
try
{
mail = Selection[1] as Outlook.MailItem;
task = Selection[1] as Outlook.TaskItem;
if (mail != null && task == null)
{
newTaskButton =
CommandBar.Controls.Add(Microsoft.Office.Core.MsoControlType.msoControlButton, missing, missing, missing, true) as Microsoft.Office.Core.CommandBarButton;
newTaskButton.Visible = true;
newTaskButton.Caption = createNewTaskPrompt;
newTaskButton.Click += ConvertMailToTaskAction;
}
else if (task != null && mail == null)
{
startWorkButton =
CommandBar.Controls.Add(Microsoft.Office.Core.MsoControlType.msoControlButton, missing, missing, missing, true) as Microsoft.Office.Core.CommandBarButton;
startWorkButton.Visible = true;
startWorkButton.Caption = startWorkingPrompt;
startWorkButton.Click += startTimerAction;
stopWorkButton =
CommandBar.Controls.Add(Microsoft.Office.Core.MsoControlType.msoControlButton, missing, missing, missing, true) as Microsoft.Office.Core.CommandBarButton;
stopWorkButton.Visible = true;
stopWorkButton.Caption = stopWorkingPrompt;
stopWorkButton.Click += stopTimerAction;
}
}
and Here is my COntextMenuClose handler:
try
{
if (newTaskButton != null)
{
newTaskButton.Click -= ConvertMailToTaskAction;
newTaskButton = null;
}
if (startWorkButton != null)
{
startWorkButton.Click -= startTimerAction;
startWorkButton = null;
}
if (stopWorkButton != null)
{
stopWorkButton.Click -= stopTimerAction;
stopWorkButton = null;
}
mail = null;
task = null;
}
The same code is behaving different and it just has me baffled. I thought
maybe it was getting run twice and made all sorts of logic to check for its
existence and stuff but nothing has prevent duplicates on my to-do bar.
Can anyone see anything I am doing wrong? Or explain the different behavior
between the to-do bar and inbox viewer pane.