【发布时间】:2008-10-14 22:27:23
【问题描述】:
我在 VS2005 中创建了一个 Interop 用户控件。当用户控件显示在 VB6 中时,它不会拾取/使用 XP 样式(按钮和选项卡看起来像 VB6 按钮/选项卡)。
当我的控件在 VB6 中时,如何让 XP 样式与我的控件一起使用?
【问题讨论】:
我在 VS2005 中创建了一个 Interop 用户控件。当用户控件显示在 VB6 中时,它不会拾取/使用 XP 样式(按钮和选项卡看起来像 VB6 按钮/选项卡)。
当我的控件在 VB6 中时,如何让 XP 样式与我的控件一起使用?
【问题讨论】:
您需要为应用程序添加清单文件,将名称为 {exefilename}.exe.manifest 的文件添加到与应用程序相同的文件夹中。
【讨论】:
清单文件仅适用于 .net 的早期版本,在 .net 1.1 之后,您可以通过编程方式激活它们。我不得不在互操作用户控件的默认构造函数中添加行Application.EnableVisualStyles()。
Public Sub New()
Application.EnableVisualStyles() '-- I added this line
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
'Raise Load event
Me.OnCreateControl()
End Sub
Microsoft's post on Application.EnableVisualStyles 解释了一切。
【讨论】: