Article ID: 170370
Article Last Modified on 5/13/2003
Private Const WM_ACTIVATE As Long = &H6
Private Const WA_INACTIVE As Integer = 0
Private Const WA_ACTIVE As Integer = 1
Private Const WA_CLICKACTIVE As Integer = 2
Function WindowProc(ByVal hw As Long, ByVal uMsg As _
Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case Msg
Case WM_ACTIVATE
Dim fActive As Integer
fActive = &HFFFF& And wparam
Select Case fActive
Case WA_INACTIVE
' Call deactivation code here
Case WA_ACTIVE
' Call activation code here
Case WA_CLICKACTIVE
' Call activation code here
Case Else
End Select
Case Else
End Select
End FunctionNOTE: If you have third-party controls on your form, they may be
subclassing the form as well. If you try to remove your subclass in this
scenario, you could crash. In these circumstances, you can just leave your
subclass in place.
"You should not get a Deactivate event if the focus is changed to another form that is not part of the VB Project containing the form that currently has the focus."
Non-modal ActiveX form
Beep
Public Sub ShowForm()
frmActiveX.Show 0 'show it modeless
End Sub
Dim oFormPrb As Object
Private Sub Command1_Click()
oFormPrb.showform
End Sub
Private Sub Form_Deactivate()
Beep
End Sub
Private Sub Form_Load()
Set oFormPrb = CreateObject("FormPrb.formclass")
End Sub170570 HOWTO: Build a Windows Message Handler with AddressOf in VB5
168795 HOWTO: Hook Into a Window's Messages Using AddressOf
Additional query words: KBAutomation kbActiveX KBComp KBDLL kbVBp kbdsd kbDSupport kbVBp500bug kbVBp600bug kbVBA
Keywords: kbbug kbprb KB170370