Quantcast
Viewing all articles
Browse latest Browse all 15772

Call Hide() but the Form is still activated on Win10

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.

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

On Win7, the debug window showing:
Quote:

Screen.ActiveForm.Name_before hide = DropdownForm
Screen.ActiveForm.Name_after hide = Form1
However, On Win10, the debug window showing:
Quote:

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.
Attached Files

Viewing all articles
Browse latest Browse all 15772

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>