Click here to Skip to main content
   

C#

 
QuestionServer.Transfer ...? Pinmemberjojoba201131-Jul-12 3:27 
AnswerRe: Server.Transfer ...? PinprotectorPete O'Hanlon31-Jul-12 3:39 
QuestionRe: Server.Transfer ...? Pinmemberjojoba201131-Jul-12 3:49 
AnswerRe: Server.Transfer ...? PinprotectorPete O'Hanlon31-Jul-12 3:54 
AnswerRe: Server.Transfer ...? PinmvpDave Kreskowiak31-Jul-12 5:32 
GeneralRe: Server.Transfer ...? PinprotectorPete O'Hanlon31-Jul-12 6:01 
GeneralRe: Server.Transfer ...? PinmemberPaul Conrad31-Jul-12 13:20 
AnswerRe: Server.Transfer ...? PinmemberShameel1-Aug-12 1:14 
QuestionProblem with BeginReceive () Callback function Pinmembertiwal31-Jul-12 0:00 
QuestionC# Monitoring Project Pinmemberstipy_terbang@yahoo.com30-Jul-12 23:47 
AnswerRe: C# Monitoring Project PinmentorWayne Gaylard31-Jul-12 0:10 
AnswerRe: C# Monitoring Project PinprotectorPete O'Hanlon31-Jul-12 0:16 
AnswerRe: C# Monitoring Project PinmvpOriginalGriff31-Jul-12 23:27 
GeneralClickEventHandler fireing twice !! [SOLVED] [modified] PinmemberRiadh1s30-Jul-12 23:14 
Hello,
I'm having a serious problem and I'm stuck with for three days now. I'm currently developping an add-in for Outlook 2007, and I'm having a toolbar and a menu bar.
The problem is, and I really don't understand why, _CommandBarButtonEvents_ClickEventHandler fires events twice, and sometimes even four times !!
 
Here is my function where I create the CommandButton elements which will be inserted in menu and tool bars :
 
public void creationBouton_SubMenu(string labelBouton, string nomRessource, Stream imgageStream, short fromToolBarOrManuBar, ref Office.CommandBarButton bouton)
        {
            Assembly ThisAssembly = Assembly.GetExecutingAssembly();
            bouton = null;
            if (fromToolBarOrManuBar == fromToolBar)
            {
                bouton = (Office.CommandBarButton)newToolBar.Controls.Add(MsoControlType.msoControlButton, missing, missing, missing, false);
                bouton.Style = Office.MsoButtonStyle.msoButtonIconAndCaptionBelow;
            }
            else if (fromToolBarOrManuBar == fromMenuBar)
            {
                bouton = (Office.CommandBarButton)_objNewMenuBar.Controls.Add(MsoControlType.msoControlButton, missing, missing, 1, true);
                bouton.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
            }
            bouton.Caption = labelBouton;
            Random random = new Random(10000);
            bouton.Tag = "Basic Tag" + random.Next(1000).ToString();    //just en ensure having different tags for each commandbutton
            imgageStream = ThisAssembly.GetManifestResourceStream(namespaceCourant + ".Resources." + nomRessource);
            bouton.Picture = MyHost.GettIPictureDispFromPicture(Image.FromStream(imgageStream));
 
            //assign the action to the buttom
            bouton.Click += new Office._CommandBarButtonEvents_ClickEventHandler(Lancement_Formualire_Event);
 
            bouton.Visible = true;
        }
 
And here where I call this method :
 
private void AddMenubar()
        {
            Stream imgageStream = null; //intialisation
            try
            {
                //Define the existent Menu Bar
                _objMenuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar;
                //Define the new Menu Bar into the old menu bar
                _objNewMenuBar = (Office.CommandBarPopup)_objMenuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, false);
                if (_objNewMenuBar != null)
                {
                    _objNewMenuBar.Caption = "RPVApp";
                    _objNewMenuBar.Tag = "RPVApp tag";
 
                    //_objNewMenuBar.OnAction

                    //Creation of submenu items
                    creationBouton_SubMenu("Nouveau message civil", "message.png", imgageStream, fromMenuBar, ref bt_NouveauMessageCivil);
  
                    creationBouton_SubMenu("Réception messages", "message2.png", imgageStream, fromMenuBar, ref bt_ReceptionMessage);
 
  
                    
                }
            }
 
And finally here the call to create the tool bar items :
 
Stream imgageStream = null; //intialisation
            if (newToolBar == null)
            {
                Office.CommandBars cmdBars = this.Application.ActiveExplorer().CommandBars;
                newToolBar = cmdBars.Add("RPVApp_Toolbar", Office.MsoBarPosition.msoBarTop, false, true);
            }
            try
            {
                //bouton Nouveau message civil
                creationBouton_SubMenu("Nouveau message civil", "message.png", imgageStream, 1, ref bt_NouveauMessageCivil);
                //bouton réceptoin messages
                creationBouton_SubMenu("Réception messages", "message2.png", imgageStream, 1, ref bt_ReceptionMessage);
                //bouton dossiers en cours

                newToolBar.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 
Thank you in advance for your help !

modified 31-Jul-12 6:25am.

AnswerRe: ClickEventHandler fireing twice !! PinprotectorPete O'Hanlon30-Jul-12 23:25 
GeneralRe: ClickEventHandler fireing twice !! PinmemberRiadh1s30-Jul-12 23:42 
GeneralRe: ClickEventHandler fireing twice !! PinprotectorPete O'Hanlon31-Jul-12 0:00 
GeneralRe: ClickEventHandler fireing twice !! PinmemberRiadh1s31-Jul-12 0:24 
GeneralRe: ClickEventHandler fireing twice !! PinprotectorPete O'Hanlon31-Jul-12 1:03 
GeneralRe: ClickEventHandler fireing twice !! PinmemberRiadh1s31-Jul-12 1:24 
GeneralRe: ClickEventHandler fireing twice !! PinprotectorPete O'Hanlon31-Jul-12 1:28 
Questionhow to clear memory PinmemberRonenb30-Jul-12 22:52 
AnswerRe: how to clear memory PinmemberEddy Vluggen31-Jul-12 0:40 
GeneralRe: how to clear memory PinmemberRonenb31-Jul-12 0:45 
AnswerRe: how to clear memory PinmemberEddy Vluggen31-Jul-12 1:10 
GeneralRe: how to clear memory PinmemberRonenb31-Jul-12 4:02 
AnswerRe: how to clear memory PinmemberEddy Vluggen31-Jul-12 4:12 
GeneralRe: how to clear memory PinprotectorPete O'Hanlon31-Jul-12 4:13 
QuestionRe: how to clear memory PinmemberEddy Vluggen31-Jul-12 4:18 
AnswerRe: how to clear memory PinprotectorPete O'Hanlon31-Jul-12 4:27 
GeneralRe: how to clear memory PinmemberEddy Vluggen31-Jul-12 6:05 
GeneralRe: how to clear memory PinmemberRonenb31-Jul-12 4:21 
AnswerRe: how to clear memory PinmemberEd Hill _5_31-Jul-12 4:20 
GeneralRe: how to clear memory PinmemberRonenb31-Jul-12 4:32 
GeneralRe: how to clear memory PinmemberEd Hill _5_31-Jul-12 4:40 
GeneralRe: how to clear memory PinmvpDave Kreskowiak31-Jul-12 5:29 
GeneralRe: how to clear memory PinmemberRonenb1-Aug-12 1:08 
AnswerRe: how to clear memory PinmemberBobJanova31-Jul-12 1:31 
AnswerRe: how to clear memory PinmemberEnnis Ray Lynch, Jr.31-Jul-12 5:52 
AnswerRe: how to clear memory PinmemberPIEBALDconsult31-Jul-12 7:09 
AnswerRe: how to clear memory PinmemberRobCroll31-Jul-12 15:31 
QuestionHelp needed in C# Pinmemberayk43930-Jul-12 22:10 
AnswerRe: Help needed in C# PinmentorWayne Gaylard30-Jul-12 22:23 
QuestionRe: Help needed in C# PinmemberEd Hill _5_30-Jul-12 23:57 
GeneralResponse.Write doenst work correctly ...? [modified] Pinmemberjojoba201130-Jul-12 21:08 
GeneralRe: Response.Write doenst work correctly ...? PinmemberBernhard Hiller30-Jul-12 21:47 
AnswerRe: Response.Write doenst work correctly ...? Pinmemberjojoba201130-Jul-12 22:31 
GeneralRe: Response.Write doenst work correctly ...? PinmvpDave Kreskowiak31-Jul-12 3:29 
QuestionHai sir PinmemberMars selva30-Jul-12 21:00 
AnswerRe: Hai sir PinmvpAbhinav S30-Jul-12 21:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web03 | 2.8.150327.1 | Last Updated 29 Mar 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid