Click here to Skip to main content
15,891,473 members
Home / Discussions / C#
   

C#

 
GeneralRe: Server.Transfer ...? Pin
Paul Conrad31-Jul-12 12:20
professionalPaul Conrad31-Jul-12 12:20 
AnswerRe: Server.Transfer ...? Pin
Shameel1-Aug-12 0:14
professionalShameel1-Aug-12 0:14 
QuestionProblem with BeginReceive () Callback function Pin
tiwal30-Jul-12 23:00
tiwal30-Jul-12 23:00 
QuestionC# Monitoring Project PinPopular
stipy_terbang@yahoo.com30-Jul-12 22:47
stipy_terbang@yahoo.com30-Jul-12 22:47 
AnswerRe: C# Monitoring Project Pin
Wayne Gaylard30-Jul-12 23:10
professionalWayne Gaylard30-Jul-12 23:10 
AnswerRe: C# Monitoring Project Pin
Pete O'Hanlon30-Jul-12 23:16
mvePete O'Hanlon30-Jul-12 23:16 
AnswerRe: C# Monitoring Project Pin
OriginalGriff31-Jul-12 22:27
mveOriginalGriff31-Jul-12 22:27 
GeneralClickEventHandler fireing twice !! [SOLVED] Pin
Riadh1s30-Jul-12 22:14
Riadh1s30-Jul-12 22: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 :

C#
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 :

C#
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 :

C#
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 !! Pin
Pete O'Hanlon30-Jul-12 22:25
mvePete O'Hanlon30-Jul-12 22:25 
GeneralRe: ClickEventHandler fireing twice !! Pin
Riadh1s30-Jul-12 22:42
Riadh1s30-Jul-12 22:42 
GeneralRe: ClickEventHandler fireing twice !! Pin
Pete O'Hanlon30-Jul-12 23:00
mvePete O'Hanlon30-Jul-12 23:00 
GeneralRe: ClickEventHandler fireing twice !! Pin
Riadh1s30-Jul-12 23:24
Riadh1s30-Jul-12 23:24 
GeneralRe: ClickEventHandler fireing twice !! Pin
Pete O'Hanlon31-Jul-12 0:03
mvePete O'Hanlon31-Jul-12 0:03 
GeneralRe: ClickEventHandler fireing twice !! Pin
Riadh1s31-Jul-12 0:24
Riadh1s31-Jul-12 0:24 
GeneralRe: ClickEventHandler fireing twice !! Pin
Pete O'Hanlon31-Jul-12 0:28
mvePete O'Hanlon31-Jul-12 0:28 
Questionhow to clear memory Pin
Ronenb30-Jul-12 21:52
Ronenb30-Jul-12 21:52 
AnswerRe: how to clear memory Pin
Eddy Vluggen30-Jul-12 23:40
professionalEddy Vluggen30-Jul-12 23:40 
GeneralRe: how to clear memory Pin
Ronenb30-Jul-12 23:45
Ronenb30-Jul-12 23:45 
AnswerRe: how to clear memory Pin
Eddy Vluggen31-Jul-12 0:10
professionalEddy Vluggen31-Jul-12 0:10 
GeneralRe: how to clear memory Pin
Ronenb31-Jul-12 3:02
Ronenb31-Jul-12 3:02 
AnswerRe: how to clear memory Pin
Eddy Vluggen31-Jul-12 3:12
professionalEddy Vluggen31-Jul-12 3:12 
GeneralRe: how to clear memory Pin
Pete O'Hanlon31-Jul-12 3:13
mvePete O'Hanlon31-Jul-12 3:13 
QuestionRe: how to clear memory Pin
Eddy Vluggen31-Jul-12 3:18
professionalEddy Vluggen31-Jul-12 3:18 
AnswerRe: how to clear memory Pin
Pete O'Hanlon31-Jul-12 3:27
mvePete O'Hanlon31-Jul-12 3:27 
GeneralRe: how to clear memory Pin
Eddy Vluggen31-Jul-12 5:05
professionalEddy Vluggen31-Jul-12 5:05 

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

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