我写了一个Add-in程序在outlook上添加Menu,但是只能点击一次,请帮忙解决一下,谢谢
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
initMenuBar();
}
private void initMenuBar()
{
Office.CommandBar menuBar = Application.ActiveExplorer().CommandBars.ActiveMenuBar;
Office.CommandBarPopup newMenuBar;
Office.CommandBarButton buttonOne;
newMenuBar = (Office.CommandBarPopup)menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true);
if (newMenuBar != null)
{
newMenuBar.Caption = "&MenuBar";
buttonOne = (Office.CommandBarButton)newMenuBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, false);
buttonOne.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
buttonOne.Caption = "button1";
buttonOne.Click += new Office._CommandBarButtonEvents_ClickEventHandler(btnConfirm_Click);
newMenuBar.Visible = true;
}
}
private void btnConfirm_Click(Office.CommandBarButton btn, ref bool cancel)
{
MessageBox.Show("Some code");
}