Public Function WindowProc(ByVal hwnd As Long, ByVal iMsg As Long, _ ByVal wParam As Long, ByVal lParam As Long) As Long Select Case iMsg ' Process left mouse button and exit Case WM_LBUTTONDOWN ' Search through controls collection ' to see if this handle belongs to a checkbox For Each ctl In frmSubClass.Controls If TypeName(ctl) = "CheckBox" Then If ctl.hwnd = hwnd Then ' Change the value If ctl.Value <= 1 Then ctl.Value = ctl.Value + 1 Else ctl.Value = 0 End If ' No default processing Exit Function End If End If Next End Select ' Call original window procedure WindowProc = CallWindowProc(hPrevWndProc, hwnd, iMsg, wParam, lParam) End Function |