Click here to Skip to main content
11,577,721 members (40,451 online)
   

C#

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

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

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
Web04 | 2.8.150603.1 | Last Updated 4 Jul 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid