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 / 309X0504.TXT < prev    next >
Encoding:
Text File  |  1998-05-27  |  1.4 KB  |  44 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.      ' un-selected, 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, light it up.
  26.           If lonCurrhWnd = UserControl.hWnd Then
  27.                mbooButtonLighted = True
  28.                UserControl.BackColor = &H0080FFFF
  29.           End If
  30.      Else
  31.           ' If the control is "lit", and it no longer
  32.           ' matches the handle of the window that the
  33.           ' cursor is on, un-light it.
  34.           If lonCurrhWnd <> UserControl.hWnd Then
  35.                mbooButtonLighted = False
  36.                UserControl.BackColor = molcBackColor
  37.           End If
  38.      End If
  39.  
  40.      ' Re-enable the timer.
  41.      tmrChkStatus.Enabled = True
  42.  
  43. End Sub
  44.