Sometimes people will take the tacky and somewhat problematic step of applying a Common Controls 6.0 manifest to VB6.exe. This seems to be about trying to test CC6 features within IDE runs.
Instead of that you can simply use the Activation Context API to select CC6 within IDE runs where you want this action to occur.
Here we have a "CC6" manifest for the IDE located within the Project folder and make use of it within Sub Main( ):
Code:
Option Explicit
Private Declare Function ActivateActCtx Lib "kernel32" ( _
ByVal hActCtx As Long, _
ByRef Cookie As Long) As Long
Private Type ACTCTXW
cbSize As Long
dwFlags As Long
lpSource As Long
wProcessorArchitecture As Integer
wLangId As Integer
lpAssemblyDirectory As Long
lpResourceName As Long
lpApplicationName As Long
hModule As Long
End Type
Private Declare Function CreateActCtxW Lib "kernel32" (ByRef ACTCTXW As ACTCTXW) As Long
Private Declare Function DeactivateActCtx Lib "kernel32" ( _
ByVal dwFlags As Long, _
ByVal Cookie As Long) As Long
Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleW" ( _
ByVal pModuleName As Long) As Long
Private Declare Function InitCommonControls Lib "Comctl32" () As Long
Private Declare Function IsUserAnAdmin Lib "Shell32" () As Long
Private Sub InitCommonControlsVB()
Const CC6_MANIFEST As String = "\CC6.manifest"
Dim ACTCTXW As ACTCTXW
Dim ActCtxCookie As Long
If GetModuleHandle(StrPtr("vb6.exe")) <> 0 Then
With ACTCTXW
.cbSize = LenB(ACTCTXW)
.lpSource = StrPtr(App.Path & CC6_MANIFEST)
End With
ActivateActCtx CreateActCtxW(ACTCTXW), ActCtxCookie
IsUserAnAdmin
InitCommonControls
DeactivateActCtx 0, ActCtxCookie
Else
IsUserAnAdmin
InitCommonControls
End If
End Sub
Private Sub Main()
InitCommonControlsVB
Form1.Show
End Sub
IDE Run
Compiled EXE Run (reverts to the default CC5 assembly)
This allows you to load the CC6 assembly for IDE runs.
If you want to do this in runs of the compiled EXE you would embed a full-featured manifest into it as a resource with ID = #1 and Type = #24. Such run-time manifests have no effect during IDE runs.
Voila. No need to hack up VB6.exe and risk the consequences for all programs. You'd only use this logic for cases where you want to do IDE testing with CC6 selected.
This version seems reliable without crashing the IDE, replace Module1.bas:
Code:
Option Explicit
Private Declare Function ActivateActCtx Lib "kernel32" ( _
ByVal hActCtx As Long, _
ByRef Cookie As Long) As Long
Private Type ACTCTXW
cbSize As Long
dwFlags As Long
lpSource As Long
wProcessorArchitecture As Integer
wLangId As Integer
lpAssemblyDirectory As Long
lpResourceName As Long
lpApplicationName As Long
hModule As Long
End Type
Private Declare Function CreateActCtxW Lib "kernel32" (ByRef ACTCTXW As ACTCTXW) As Long
Private Declare Function DeactivateActCtx Lib "kernel32" ( _
ByVal dwFlags As Long, _
ByVal Cookie As Long) As Long
Private Declare Function GetCurrentActCtx Lib "kernel32" (ByRef hActCtx As Long) As Long
Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleW" ( _
ByVal pModuleName As Long) As Long
Private Declare Function InitCommonControls Lib "Comctl32" () As Long
Private Declare Function IsUserAnAdmin Lib "Shell32" () As Long
Private ActCtxCookie As Long
Private Sub InitCommonControlsVB()
Const CC6_MANIFEST As String = "\CC6.manifest"
Dim Success As Boolean
Dim hActCtx As Long
Dim ACTCTXW As ACTCTXW
If GetModuleHandle(StrPtr("vb6.exe")) <> 0 Then
Success = GetCurrentActCtx(hActCtx) <> 0
If Not Success Or hActCtx = 0 Then
With ACTCTXW
.cbSize = LenB(ACTCTXW)
.lpSource = StrPtr(App.Path & CC6_MANIFEST)
End With
ActivateActCtx CreateActCtxW(ACTCTXW), ActCtxCookie
End If
IsUserAnAdmin
InitCommonControls
Else
IsUserAnAdmin
InitCommonControls
End If
End Sub
Private Sub Main()
InitCommonControlsVB
Form1.Show
If ActCtxCookie <> 0 Then DeactivateActCtx 0, ActCtxCookie
End Sub
Something strange is going on with the timing of the creation of the default instance of Form1.
This attachment adds a Form2, which gets shown by clicking the button on Form1.
Last edited by dilettante; Dec 24th, 2018 at 02:14 AM.