0

When we create a new WinForms app project in VS.NET, the following template code is used for the main procedure of the app:

static void Main()
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new Form1());
}

What is the purpose of calling Application.SetCompatibleTextRenderingDefault with its defaultValue parameter set to false if all WinForms controls like Label and Button we place on forms have the UseCompatibleTextRendering property set to false by default?

TecMan
  • 2,743
  • 2
  • 30
  • 64
  • No. It was a compatibility option for programs written in .NET 1.x. Without it such a program could look poorly in .NET 2.0 with text no longer fitting as it did back in 1.1. Back-compat is pretty sacred to Microsoft. – Hans Passant Feb 08 '18 at 12:18
  • Then the right way to process this situation is to add Application.SetCompatibleTextRenderingDefault(**true**) to old programs that come from .NET 1.x. If we create a new app in VS 2005+, then the setting we are talking about is really useless, redundant and misleading. I thought there could be a hidden effect of doing Application.SetCompatibleTextRenderingDefault(false) in .NET 2.0+ apps I have not discovered yet... – TecMan Feb 08 '18 at 13:07
  • Well, of course not. A program written in 1.x days does not contain this call, the method did not exist yet. So the default must be false to get back-compat behavior. There is excessively little reason to fret about this, project templates for the past 13 years already do this without assistance. – Hans Passant Feb 08 '18 at 13:39
  • @HansPassant, am I missing something? We get GDI+ rendering from .NET 1.x in WinForms controls if we call Application.SetCompatibleTextRenderingDefault(true). But this is not the default mode of .NET 2.0+, which is equivalent to Application.SetCompatibleTextRenderingDefault(false). – TecMan Feb 08 '18 at 14:52

0 Answers0