Перейти к основному контенту
Центр разработки для Windows

 none
Using SetCompatibleTextRenderingDefault in VB RRS feed

  • Вопрос

  • Hi,

    My question is I need to use Sub Main function to start my app in VB. But, the button property "UseCompatibleTextRendering" usually set to true after i started my app automatically. So, I want to use SetCompatibleTextRendering method to set the default value for the property "UseCompatibleTextRendering" of button.

    How can I use SetCompatibleTextRenderingDefault method in Sub Main function since there was throwed InvalidOperationException.

    Also, I readed msdn document about WindowsFormsApplicationBase.UseCompatibleTextRendering, but it should be enable Application Framework in project property. there was not support to set the app start from Sub Main.


    I holp that you can understand my meaning. I will try to explain my idea to better.

Ответы

  • The following worked for me.

    1.  Start new VB.NET project.
    2.  Turn off Enable application framework.   Choose to run Sub Main as the Startup object.
    3.  Add a Module file as follows:

    Module Module1
        Sub Main()
            Application.EnableVisualStyles()
            Application.SetCompatibleTextRenderingDefault(False)
            Application.Run(New Form)
        End Sub
    End Module
    Are you running this program directly (not trying anything fancy that involves other code)? 

    Does your module have any variables that initialize like the following.  This will cause problems because this New will happen prior to Sub Main:

    Private ThisIsAProblem As New Form
    Your process should not have created any windows or controls prior to the calling of SetCompatibleTextRenderingDefault.



    • Помечено в качестве ответа Tze Ying 5 июня 2009 г. 5:52

Все ответы