Hi
I have a .net class library with a com class that calls a form.
I want to to SetCompatibleTextRenderingDefault(false)
to ensure the form fonts look nice.
If I run the command in the class constructor I get the following error:
SetCompatibleTextRenderingDefault must be called before the first IWin32Window object is created in the application.
Where can/should I run this? Surely there is no earlier place than sub New!
Thank in advance
Jon
Edit1: To clarify, I get this error when initiating the class from a .net test harness, if I call it from a VB6 app then I simply get "Automation Error"
Edit2: Is the answer that I cannot use SetCompatibleTextRenderingDefault
in a com class when calling from a vb6 app?? Maybe it's the "parent" app that needs to call this method and as such a vb6 app cannot?
Edit3: Maybe I am asking this question in the wrong way! - Maybe the question is: how can I make the fonts look nice in a .net class library form called from a vb6 app?
-
Place this inside the application startup code before the first window is created. Under C# this would be the main routine that then creates the initial window.
wheelibin : Because this is a class which has a function calling the form, then I was under the impression that sub New is the "application startup code"? -
A possible workaround would be to set the property manually on all buttons and labels in the form constructor:
public Form1() { InitializeComponent(); DisableCompatibleTextRendering(this); } private static void DisableCompatibleTextRendering(Control c) { var button = (c as ButtonBase); var label = (c as Label); if (button != null) { button.UseCompatibleTextRendering = false; } if (label != null) { label.UseCompatibleTextRendering = false; } foreach (var child in c.Controls.Cast<Control>()) { DisableCompatibleTextRendering(child); } }
wheelibin : I'll do it this way...thanks for your answer :)
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.