none
How to obtain the window(inspector) colors of the theme applied currently? RRS feed

  • Question

  • Dear professionals,

    Could you tell me how to get the foreground or background color of the current inspector or explorer window in an Outlook 2016 VSTO add-in?

    Each color in Add-in's original forms should be applied as same as current theme.

    Thank you in advance.




    Tuesday, December 18, 2018 1:54 AM

All replies

  • Hi Always,

    May I know what you want to do after you get it?

    If you want to change it, unfortunately, can't do that. The color of the explorer window is determined by the Office theme.

    You can change the control background and foreground color.

    For more information, please see the following link:

    How change the background and foreground on the Office Ribbon

    Control.Background Property

    Control.Foreground Property

    Hopefully it helps you.

    Best Regards,

    Lina


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Tuesday, December 18, 2018 7:03 AM
  • Dear Lina,

    Thank you for your reply.

    I want to set the background color as same as the current theme to my original windows forms in my add-in.

    For example:

    When Application.ItemSend event fired, add-in generates the original windows form inherited from System.Windows.Forms.Form class and applies its foreground color and background color as same as current office theme's.

    In other words: I want to know how to obtain each color code of current office theme.

    namespace MySampleAddIn { public partial class ThisAddIn { private void ThisAddIn_Startup(object sender, System.EventArgs e) { this.Application.ItemSend += Application_ItemSend; } private void Application_ItemSend(object Item, ref bool Cancel) { var mailItem = Item as Outlook.MailItem; if (mailItem == null) return; using(var dialog = new ConfirmForm()) { dialog.ForeColor = System.Drawing.SystemColors.ControlText; // <--- CurrentTheme.ForeColor !? dialog.BackColor = System.Drawing.SystemColors.Window; // <--- CurrentTheme.BackColor !? if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { Cancel = true; return; } } } //... } }

    // ---

    using System.Windows.Forms;

    namespace MySampleAddIn
    {
        public partial class ConfirmForm : Form
        {
            public ConfirmForm()
            {
                InitializeComponent();
            }
    // ...
        }
    }

    Thank you in advance.





    Tuesday, December 18, 2018 7:30 AM
  • I'm going to apply the Office UI guideline on this article to my original windows forms in my VSTO add-in.

    https://docs.microsoft.com/gl-es/office/dev/add-ins/design/add-in-color

    And also, I found these articles.

    https://docs.microsoft.com/en-us/javascript/api/office/office.context?view=office-js

    https://docs.microsoft.com/en-us/javascript/api/office/office.officetheme?view=office-js

    How can I access these properties of the office.officetheme object or similar objects in C#? (JavaScript only?)

    Wednesday, December 19, 2018 1:18 AM
  • Hi Always,

    Please see the following links:

    Get current Office theme

    Getting Hex Color from Word Theme color

    Hopefully it helps you.

    Best Regards,

    Lina


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Thursday, December 20, 2018 6:16 AM
  • Hi Always,

    Thanks for your asking. Please remember to mark the replies as answers if they helped and please help us close the thread.

     

    Thank you for understanding. If you have any question, or update, please feel free to let us know.

     

    I wish you a happy life!

     

    Best Regards,

     

    Lina


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Wednesday, December 26, 2018 6:02 AM