Private Declare Function InitCommonControlsEx Lib "comctl32.dll" _ (iccex As tagInitCommonControlsEx) As Boolean
Private Type tagInitCommonControlsEx
lngSize As Long
lngICC As Long
End Type
Private Const ICC_USEREX_CLASSES = &H200
这里我们编写一个函数封装初始化操作:
Public Function InitCommonControlsVB() As Boolean
On Error Resume Next
Dim iccex As tagInitCommonControlsEx
With iccex
.lngSize = LenB(iccex)
.lngICC = ICC_USEREX_CLASSES
End With
InitCommonControlsEx iccex
InitCommonControlsVB = (Err.Number = 0)
On Error Goto 0
End Function
注意初始化动作必须在所有窗体加载前完成,所以要把相关语句放到Sub Main()中,并设置工程从Sub Main()启动。代码如下: