none
Outlook 2007 CommandBarButton Icon getting black background RRS feed

  • Question

  • I am trying to make an outlook 2007 addIn. While setting an icon to the CommandBarButton the icon's background is turning black.

    Black background commandBarButtton

    The code I am using is

        private CommandBar _menuBar;
       
    private void AddScheduleMeetingButton()
       
    {
           
    var scheduleButton = (CommandBarButton)_menuBar
                       
    .Controls.Add(MsoControlType.msoControlButton, missing, missing, 1, true);

            scheduleButton
    .BeginGroup = true;
            scheduleButton
    .Caption = ScheduleButtonCaption;
            scheduleButton
    .Picture = GetImage(Resources.schedule_meeting16);
            scheduleButton
    .Style = MsoButtonStyle.msoButtonIconAndCaption;
            scheduleButton
    .Click += UnirowScheduleButtonClick;
            scheduleButton
    .Visible = true;
       
    }

    GetImage function using the AxHost approach given by microsoft

        private IPictureDisp GetImage(Icon newIcon)
       
    {
           
    IPictureDisp tempImage = null;
           
    try
           
    {

               
    var newImageList = new ImageList();
                newImageList
    .Images.Add(newIcon);

                tempImage
    = MyHost.GetIPictureDispFromPicture(newImageList.Images[0]);
           
    }
           
    catch (Exception ex)
           
    {
               
    MessageBox.Show(ex.Message);
           
    }
           
    return tempImage;
       
    }

    What is the mistake I am doing?


    M S Prakash Kumar

    Sunday, September 16, 2012 2:24 AM

Answers

  • CommandBarButton backgrounds should use separate images for the Picture and Mask properties. The Mask property should have the masking where you desire transparency. See http://msdn.microsoft.com/en-us/library/office/aa338202(v=office.12).aspx

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "msprakashkumar" <=?utf-8?B?bXNwcmFrYXNoa3VtYXI=?=> wrote in message news:750cde83-fa81-4794-b53f-ae75791298ab...

    I am trying to make an outlook 2007 addIn. While setting an icon to the CommandBarButton the icon's background is turning black.

    Black background commandBarButtton

    The code I am using is

        private CommandBar _menuBar;
       
    private void AddScheduleMeetingButton()
       
    {
           
    var scheduleButton = (CommandBarButton)_menuBar
                       
    .Controls.Add(MsoControlType.msoControlButton, missing, missing, 1, true);

            scheduleButton
    .BeginGroup = true;
            scheduleButton
    .Caption = ScheduleButtonCaption;
            scheduleButton
    .Picture = GetImage(Resources.schedule_meeting16);
            scheduleButton
    .Style = MsoButtonStyle.msoButtonIconAndCaption;
            scheduleButton
    .Click += UnirowScheduleButtonClick;
            scheduleButton
    .Visible = true;
       
    }

    GetImage function using the AxHost approach given by microsoft

        private IPictureDisp GetImage(Icon newIcon)
       
    {
           
    IPictureDisp tempImage = null;
           
    try
           
    {

               
    var newImageList = new ImageList();
                newImageList
    .Images.Add(newIcon);

                tempImage
    = MyHost.GetIPictureDispFromPicture(newImageList.Images[0]);
           
    }
           
    catch (Exception ex)
           
    {
               
    MessageBox.Show(ex.Message);
           
    }
           
    return tempImage;
       
    }

    What is the mistake I am doing?


    M S Prakash Kumar


    Ken Slovak MVP - Outlook
    Monday, September 17, 2012 6:38 PM