开发者

Application.SetCompatibleTextRenderingDefault(false);

Application.SetCompatibleTextRenderingDefault(false);

Error:

Before the establishment of the first object IWin32Window in the annex to call SetCompatibleTextRenderingDefault.

Why error? How to avoid? What does SetCompatibleTextRenderingDefault开发者_Go百科 actually do?


Back in .NET 1.x, the GDI+ Graphics class was used to render certain controls. Due to performance issues, this approach was scrapped thus .NET version 2.0 and later use the GDI TextRenderer class instead.

Calling SetCompatibleTextRenderingDefault(true) forces some controls to use their old, pre-2.0 rendering.

Unless you are upgrading a .NET 1.x application, and need to keep the old style, you should always use SetCompatibleTextRenderingDefault(false). Or you can remove this call entirely; since false is the default, an explicit false call is not necessary.

Further reading can be found at the relevant MSDN page.


Update: as stated in the comments, the answer was wrong. I changed it below and referenced the MSDN article instead of rephrasing it.

As the docs state, you have to call this before creating your first window.

It sets the default rendering engine for some controls: GDI+ if true, GDI if false. See this MSDN article for all the details.


defaultValue Type: System.Boolean The default value to use for new controls. If true, new controls that support UseCompatibleTextRendering use the GDI+ based Graphics class for text rendering; if false, new controls use the GDI based TextRenderer class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜