I have a dropdown Form to show some tips by clicking a button. The codes work on Win7 and XP for many years but it has problem on Win10.
On Win7, the debug window showing:
Screen.ActiveForm.Name_before hide = DropdownForm
Screen.ActiveForm.Name_after hide = Form1
However, On Win10, the debug window showing:
Screen.ActiveForm.Name_before hide = DropdownForm
Screen.ActiveForm.Name_after hide = DropdownForm
I have tested on C#, it has the same problem, so it is quite confirmed that MS has changed something?
Edited: The demo used Krool's Subclass, which may need reference OLEGuild.tlb and just for demostration of the problem.
Code:
Option Explicit
Implements ISubclass
Private Const WM_ACTIVATE As Long = &H6
Private m_bActivated As Boolean
Private Sub Form_Deactivate()
'Debug.Print " Screen.ActiveForm.Name_Form_Deactivate_before hide = " & Screen.ActiveForm.Name: Call DropdownForm.Hide: Debug.Print " Screen.ActiveForm.Name_Form_Deactivate_after hide = " & Screen.ActiveForm.Name
End Sub
Private Sub Form_Initialize()
'Call ComCtlsLoadShellMod
'Call ComCtlsSetSubclass(DropdownForm.hWnd, Me, 0)
End Sub
Private Sub Form_Load()
Call ComCtlsSetSubclass(DropdownForm.hWnd, Me, 0)
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Call ComCtlsReleaseShellMod
Call ComCtlsRemoveSubclass(DropdownForm.hWnd)
End Sub
Private Function ISubclass_Message(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long, ByVal dwRefData As Long) As Long
Select Case dwRefData
Case 0
ISubclass_Message = WindowProcControl(hWnd, wMsg, wParam, lParam)
End Select
End Function
Private Function WindowProcControl(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case wMsg
Case WM_ACTIVATE
'Debug.Print "wParam = " & CStr(wParam)
'Debug.Print "lParam = " & CStr(lParam)
If wParam = 1 Then m_bActivated = True
If wParam = 0 And m_bActivated Then m_bActivated = False: Debug.Print " Screen.ActiveForm.Name_before hide = " & Screen.ActiveForm.Name: Call DropdownForm.Hide: Debug.Print " Screen.ActiveForm.Name_after hide = " & Screen.ActiveForm.Name
End Select
WindowProcControl = ComCtlsDefaultProc(hWnd, wMsg, wParam, lParam)
End Function
Quote:
Screen.ActiveForm.Name_before hide = DropdownForm
Screen.ActiveForm.Name_after hide = Form1
Quote:
Screen.ActiveForm.Name_before hide = DropdownForm
Screen.ActiveForm.Name_after hide = DropdownForm
Edited: The demo used Krool's Subclass, which may need reference OLEGuild.tlb and just for demostration of the problem.