2008-10-14 54 views
1

我在VS2005中创建了一个Interop用户控件。当用户控件显示在VB6中时,它不会拾取/使用XP样式(按钮和选项卡看起来像VB6按钮/选项卡)。互操作控件没有采用XP样式

如何让XP样式在VB6中与我的控件一起使用?

回答

1

清单文件只适用于早期版本的.net和.net 1.1之后,您可以通过编程方式激活它们。我必须在interop用户控件的默认构造函数中添加行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


@marioh - 谢谢你的回应。

1

您需要为应用程序添加清单文件,将名称为{exefilename} .exe.manifest的文件添加到与应用程序相同的文件夹中。

+0

那记得我关于VB6和XP的老纪念品:) – 2008-10-14 22:38:46