home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 6 Unleashed…sional Reference Edition) / Visual_Basic_6_Unleashed_Professional_Reference_Edition_Sams_1999.iso / Source / CHAP05 / 309X0517.TXT < prev    next >
Encoding:
Text File  |  1998-05-27  |  2.0 KB  |  60 lines

  1.  
  2. Private Sub tmrChkStatus_Timer()
  3.  
  4.     ' This event will fire about 4 times per second,
  5.     ' and is used to see if the control's status
  6.     ' changes from selected ("lighted") to
  7.     ' unselected, and vice versa.
  8.  
  9.     Dim lonCStat As Long
  10.     Dim lonCurrhWnd As Long
  11.  
  12.     ' Disable the timer temporarily.
  13.     tmrChkStatus.Enabled = False
  14.  
  15.     ' Using two Windows API functions, determine the
  16.     ' handle of the window that the cursor is
  17.     ' currently positioned on.
  18.     lonCStat = GetCursorPos&(mpoiCursorPos)
  19.     lonCurrhWnd = WindowFromPoint(mpoiCursorPos.X, _
  20.          mpoiCursorPos.Y)
  21.  
  22.     If mbooButtonLighted = False Then
  23.         ' If the control is not currently "lighted",
  24.         ' and it matches the handle of the window that
  25.         ' the cursor is on, either light it up (if
  26.         ' ButtonMode = Text Only Mode) or switch its
  27.         ' background image to the one that indicates
  28.         ' that the button is selected.
  29.         If lonCurrhWnd = UserControl.hWnd Then
  30.             mbooButtonLighted = True
  31.             If mmodButtonMode = [Text Only Mode] Then
  32.                 UserControl.BackColor = molcSelColor
  33.             Else
  34.                 Set UserControl.Picture = mpicSelPicture
  35.             End If
  36.             RaiseEvent StatusChanged(1)
  37.         End If
  38.     Else
  39.         ' If the control is "lit", and it no longer
  40.         ' matches the handle of the window that the
  41.         ' cursor is on, either un-light it (if
  42.         ' ButtonMode = Text Only Mode) or switch its
  43.         ' background image to the one that indicates
  44.         ' that the button is not selected.
  45.         If lonCurrhWnd <> UserControl.hWnd Then
  46.             mbooButtonLighted = False
  47.             If mmodButtonMode = [Text Only Mode] Then
  48.                 UserControl.BackColor = molcBackColor
  49.             Else
  50.                 Set UserControl.Picture = mpicPicture
  51.             End If
  52.             RaiseEvent StatusChanged(0)
  53.         End If
  54.     End If
  55.  
  56.     ' Re-enable the timer.
  57.     tmrChkStatus.Enabled = True
  58.  
  59. End Sub
  60.