using EnableVisualStyles() for windows form?

using EnableVisualStyles() for windows form?

vkpunique
Advocate Advocate
781 Views
4 Replies
Message 1 of 5

using EnableVisualStyles() for windows form?

vkpunique
Advocate
Advocate

My current windows form in autocad .net addin looks bit pixelated specially fonts.

vkpunique_0-1673422586774.png

so I am using System.Windows.Forms.Application.EnableVisualStyles() in Initialization class

   public void Initialize()
        {
            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
 
            Autodesk.AutoCAD.ApplicationServices.Core.Application.Idle += LoadRibbonMenuOnIdle;
        }

New Updated Look, both looks same but pay special attention to fonts.

vkpunique_1-1673422757414.png

I just want to know if i am using this correctly? Is there any other way to do this? Can i place EnableVisualization Code to other location?

0 Likes
Accepted solutions (1)
782 Views
4 Replies
Replies (4)
Message 2 of 5

_gile
Consultant
Consultant

Hi,

I do not have such problem with my dialogs , neither with WinForm nor with WPF.

WinForm:

_gile_0-1673428651134.png

 

WPF:

_gile_2-1673428797542.png

How do you show your dialogs ?

You should use Application.ShowModalDialog (WinForm) or Application.ShowModalWindow (WPF).

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 5

vkpunique
Advocate
Advocate

I am using Form.ShowDialog(), I did tried your application.showmodeldialog(frm) but without enablevisualstyle it looks pixelated too. 😞 may be something wrong with my autocad settings?

        [CommandMethod(nameof(GetBlockData))]
        public static void GetBlockData()
        {
            var frm = new GetBlockDataForm();
            frm.ShowDialog();
        }

 Also @_gile can i have access to that inspector app? That looks handly to observer autocad drawing database live.

0 Likes
Message 4 of 5

_gile
Consultant
Consultant
Accepted solution

From the developper's documentation:

"Custom dialog boxes or forms in the AutoCAD Managed .NET API extend the classes from the System.Windows.Forms namespace directly. However, such applications should not call the Form.ShowDialog method but instead use the Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog and ShowModelessDialog methods to display their custom forms. Using Form.ShowDialog in an AutoCAD extension application may result in unexpected behavior."

 

Inspector is available on GitHub.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 5 of 5

vkpunique
Advocate
Advocate

Okay, i'll use Application.ShowModalDialog().

Inspector app looks like great utility. Thanks for sharing.

I still don't know why my forms looks pixelated without EnableVisualStyles(); 

0 Likes