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 / 309X0513.TXT < prev    next >
Encoding:
Text File  |  1998-05-27  |  2.0 KB  |  58 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, 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.           End If
  37.      Else
  38.           ' If the control is "lit", and it no longer
  39.           ' matches the handle of the window that the
  40.           ' cursor is on, either un-light it (if
  41.           ' ButtonMode = Text Only Mode) or switch its
  42.           ' background image to the one that indicates
  43.           ' that the button is not selected.
  44.           If lonCurrhWnd <> UserControl.hWnd Then
  45.                mbooButtonLighted = False
  46.                If mmodButtonMode = [Text Only Mode] Then
  47.                     UserControl.BackColor = molcBackColor
  48.                Else
  49.                     Set UserControl.Picture = mpicPicture
  50.                End If
  51.           End If
  52.      End If
  53.  
  54.      ' Re-enable the timer.
  55.      tmrChkStatus.Enabled = True
  56.  
  57. End Sub
  58.