home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / keysta / keystate.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-01-22  |  3.4 KB  |  107 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Double-Click to Change Key State"
  6.    ClientHeight    =   675
  7.    ClientLeft      =   2220
  8.    ClientTop       =   3165
  9.    ClientWidth     =   5325
  10.    Height          =   1080
  11.    KeyPreview      =   -1  'True
  12.    Left            =   2160
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   675
  17.    ScaleWidth      =   5325
  18.    Top             =   2820
  19.    Width           =   5445
  20.    Begin Timer Timer1 
  21.       Interval        =   250
  22.       Left            =   4800
  23.       Top             =   120
  24.    End
  25.    Begin Label Label3 
  26.       AutoSize        =   -1  'True
  27.       BackStyle       =   0  'Transparent
  28.       Caption         =   "Num Lock:"
  29.       Height          =   195
  30.       Index           =   1
  31.       Left            =   2640
  32.       TabIndex        =   3
  33.       Top             =   240
  34.       Width           =   930
  35.    End
  36.    Begin Label Label3 
  37.       AutoSize        =   -1  'True
  38.       BackStyle       =   0  'Transparent
  39.       Caption         =   "Caps Lock:"
  40.       Height          =   195
  41.       Index           =   0
  42.       Left            =   240
  43.       TabIndex        =   2
  44.       Top             =   240
  45.       Width           =   975
  46.    End
  47.    Begin Label Label2 
  48.       Alignment       =   2  'Center
  49.       BackColor       =   &H000000FF&
  50.       BorderStyle     =   1  'Fixed Single
  51.       Caption         =   "Label2"
  52.       FontBold        =   -1  'True
  53.       FontItalic      =   0   'False
  54.       FontName        =   "MS Sans Serif"
  55.       FontSize        =   12
  56.       FontStrikethru  =   0   'False
  57.       FontUnderline   =   0   'False
  58.       ForeColor       =   &H00FFFFFF&
  59.       Height          =   330
  60.       Left            =   3720
  61.       TabIndex        =   1
  62.       Top             =   120
  63.       Width           =   885
  64.    End
  65.    Begin Label Label1 
  66.       Alignment       =   2  'Center
  67.       BackColor       =   &H000000FF&
  68.       BorderStyle     =   1  'Fixed Single
  69.       Caption         =   "Label1"
  70.       FontBold        =   -1  'True
  71.       FontItalic      =   0   'False
  72.       FontName        =   "MS Sans Serif"
  73.       FontSize        =   12
  74.       FontStrikethru  =   0   'False
  75.       FontUnderline   =   0   'False
  76.       ForeColor       =   &H00FFFFFF&
  77.       Height          =   330
  78.       Left            =   1320
  79.       TabIndex        =   0
  80.       Top             =   120
  81.       Width           =   885
  82.    End
  83. ' KeyState.Frm - Demo display of and setting Caps and Num Lock
  84. ' 95/01/22 Copyright 1995, Larry Rebich, The Bridge, Inc.
  85. ' See the text in KeyState.Bas for a description of this "workaround"
  86.     Option Explicit
  87.     DefInt A-Z
  88. Sub Form_KeyPress (KeyAscii As Integer)
  89.     If KeyAscii = 27 Then End       'esc pressed
  90. End Sub
  91. Sub Form_Load ()
  92.     Timer1_Timer                'get state right now
  93.     'Center Me is nicer
  94.     Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2 * .85
  95. End Sub
  96. Sub Label1_DblClick ()
  97.     SetKeyboardStateCapsLock    'toggle it
  98. End Sub
  99. Sub Label2_DblClick ()
  100.     SetKeyboardStateNumLock     'toggle it
  101. End Sub
  102. Sub Timer1_Timer ()
  103. ' 95/01/22 Get the current setting every so often.
  104.     Label1.Caption = GetKeyboardStateCapsLock()
  105.     Label2.Caption = GetKeyboardStateNumLock()
  106. End Sub
  107.