c# – 从MMC管理单元显示时,表单具有不同的样式

我在MMC管理单元中显示一个对话框.从结果窗格中调用对话框时,它具有
Windows主题.

但是,从管理单元范围窗格上下文菜单调用对话框时,它具有不同的样式.

管理单元用C语言编写,对话框是C#表单. C代码通过COM调用C#代码.

最佳答案 调用
Application.EnableVisualStyles()可为您的应用程序启用视觉样式.在应用程序中,该方法通常在应用程序的Main方法中调用.但在这种情况下,您可以在窗体的构造函数中调用Application.EnableVisualStyles():

public Form1()
{
    InitializeComponent();
    Application.EnableVisualStyles();
}

07001

This method enables visual styles for the application. Visual styles
are the colors, fonts, and other visual elements that form an
operating system theme. Controls will draw with visual styles if the
control and the operating system support it. To have an effect,
EnableVisualStyles() must be called before creating any controls in
the application; typically, EnableVisualStyles() is the first line in
the Main function.

点赞