2011-05-11 3 views
1

Outlook에 메뉴를 추가하는 Outlook 추가 기능을 쓰고 있습니다. 위임을 대리인에게 한 번 호출 한 후에 제거되는 것 같습니다. 메뉴 항목을 한 번 클릭합니다. 다음에 사용자가 클릭하면 내 대리인에게 전달되지 않습니다. 코드 예제 : 나는 메뉴의 순서를 어떻게해야onclick 대리인이 한 번만 트리거됩니다.

menuCommand = (Office.CommandBarButton)cmdBarControl.Controls.Add(
Office.MsoControlType.msoControlButton, missing, missing, missing, true); 

menuCommand.Caption = "&Generate weekly..."; 
menuCommand.Tag = "Generate"; 
menuCommand.FaceId = 65; 

menuCommand.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(
menuCommand_Generate_Click); 

menuCommand = (Office.CommandBarButton)cmdBarControl.Controls.Add(
    Office.MsoControlType.msoControlButton, missing, missing, missing, true); 

menuCommand.Caption = "&About"; 
menuCommand.Tag = "About"; 
menuCommand.FaceId = 65; 

menuCommand.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(
menuCommand_About_Click); 
menuCommand.BeginGroup = true; 

액션마다 트리거?

+0

무엇이 질문입니까? – jv42

+0

나는 그것을 분명히했다. – oshai

답변

1

menuitem은 로컬 변수입니까? , 그러면 가비지 수집기가 범위를 벗어나면 정리할 수 있습니다.

변수를 전역 개체로 유지하십시오.

+0

만약'menuCommand'를 뜻한다면 로컬이 아닙니다. – oshai

+1

두 번째 버튼에 동일한 변수를 다시 사용하고 있습니다. 그러면 첫 번째 단추가 가비지 수집 대상이됩니다. –

+0

고마워요! 이 문제가 해결되었습니다. – oshai