【问题标题】:Interop Controls not picking up XP Styles互操作控件未选择 XP 样式
【发布时间】:2008-10-14 22:27:23
【问题描述】:

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

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

【问题讨论】:

    标签: .net winforms vb6 interop


    【解决方案1】:

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

    【讨论】:

    • 那记得我关于 VB6 和 XP 的旧纪念品 :)
    【解决方案2】:

    清单文件仅适用于 .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 解释了一切。


    @marioh - 感谢您的回复。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-10
      • 2010-10-21
      相关资源
      最近更新 更多