none
Outlook addin project - EnableVisualStyles RRS feed

  • Question

  • I am opening a windows forms application in a outlook addin project in Visual Studio 2010. I notice that the styles are not enabled - and it is essential that I enable them. I need to add the following line of code to outlooks Process:

    System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Application.EnableVisualStyles();

    Can anyone help me accomplish this?


    Watson

    Monday, October 8, 2012 4:55 PM

Answers

  • If you want to set those values do so in the Startup event handler.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Blast" <=?utf-8?B?Qmxhc3Q=?=> wrote in message news:ca33c18d-3556-47dc-9723-163ee4822a57...

    I am opening a windows forms application in a outlook addin project in Visual Studio 2010. I notice that the styles are not enabled - and it is essential that I enable them. I need to add the following line of code to outlooks Process:

    System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Application.EnableVisualStyles();

    Can anyone help me accomplish this?


    Watson


    Ken Slovak MVP - Outlook
    • Marked as answer by Blast Monday, October 8, 2012 10:59 PM
    Monday, October 8, 2012 8:59 PM

All replies

  • I am opening a windows forms application in a outlook addin project in Visual Studio 2010. I notice that the styles and SetCompatibleTextRenderingDefault are not set correctly- and it is essential that I set them. I need to add the following line of code to outlooks Process:

    System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Application.EnableVisualStyles();

    Can anyone help me accomplish this?


    Watson

    Monday, October 8, 2012 7:39 PM
  • If you want to set those values do so in the Startup event handler.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Blast" <=?utf-8?B?Qmxhc3Q=?=> wrote in message news:ca33c18d-3556-47dc-9723-163ee4822a57...

    I am opening a windows forms application in a outlook addin project in Visual Studio 2010. I notice that the styles are not enabled - and it is essential that I enable them. I need to add the following line of code to outlooks Process:

    System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Application.EnableVisualStyles();

    Can anyone help me accomplish this?


    Watson


    Ken Slovak MVP - Outlook
    • Marked as answer by Blast Monday, October 8, 2012 10:59 PM
    Monday, October 8, 2012 8:59 PM
  • Please don't post the same question in multiple forums. See my answer in the VSTO forum where you also asked the same question.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Blast" <=?utf-8?B?Qmxhc3Q=?=> wrote in message news:18dd5cef-833b-4ef5-8dd7-a478164aaba0...

    I am opening a windows forms application in a outlook addin project in Visual Studio 2010. I notice that the styles and SetCompatibleTextRenderingDefault are not set correctly- and it is essential that I set them. I need to add the following line of code to outlooks Process:

    System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Application.EnableVisualStyles();

    Can anyone help me accomplish this?


    Watson


    Ken Slovak MVP - Outlook
    Monday, October 8, 2012 9:01 PM
  • Sorry I was asked to redirect this here. Also I don't think your answer was helpful - I appreciate the attempt but i've tried all the basic things I can think of to get this to work.

    Watson


    • Edited by Blast Monday, October 8, 2012 9:28 PM
    Monday, October 8, 2012 9:13 PM
  • There is no event handler I have found that works. Can you detail where this startup even handler is, what class or project file?

    I have pasted the following code:

    System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Application.EnableVisualStyles();

    in the following places:

    ThisAddIn.cs:

    privatevoidInternalStartup(){} //Doesn't work 

    public override void BeginInit(){ base.BeginInit() } // Doesn't work

    privatevoidThisAddIn_Startup(objectsender, System.EventArgse){} //doesn't work

    This.AddIn.Designer.cs

    publicThisAddIn(global::Microsoft.Office.Tools.Outlook.Factoryfactory, global::System.IServiceProviderserviceProvider) :

    base(factory, serviceProvider, "AddIn", "ThisAddIn") {} // Doesn't work

    Basically, I've tried everywhere I can think of. I've tried using the following but again it doesn't work http://support.microsoft.com/kb/830033 

    Also, this may work but I don't think it works for Visual Studio 2010, I think this is meant for 2008 - but I think this at the time did resolve this issue http://support.microsoft.com/?kbid=302901 but i'm not entirely sure.


    Watson



    • Edited by Blast Monday, October 8, 2012 9:33 PM
    Monday, October 8, 2012 9:23 PM
  • Scrapping my current addin and creating a new addin. I am able to set the code correctly like you suggest. The bug must lay within this the addin I was trying use ( I didn't write the code :P )

    Anyway thank you very much - I'll do some digging and figure out why I am unable to get this to work in the other addin that was created. I'll post back here if I figure it out.


    Watson

    Monday, October 8, 2012 9:50 PM
  • Newing up a Windows Forms as a class variable was the culprit.

    for example,

    public partial class ThisAddIn

    {

    Wndowsform _myform = new Wndowsform(); //This casues problem

    private void InterntalStartup()

    {

     Application.SetCompatibleTextRenderingDefault(false);

    Throws following error:

    SetCompatibleTextRenderingDefault must be called before the first IWin32Window object is created in the application.

    }

    Just set your class variable to null: Wndowsform _myform = null; and new up in the startup event. Which I'm not sure why this wasn't done in the first place but there ya go. Anyway that fixes the issue thanks a lot.

    }


    Watson

    Monday, October 8, 2012 10:14 PM