home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 5 Developer's Kit / vb5 dev kit.iso / dev / jdsaver / passchek.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-09-13  |  5.7 KB  |  179 lines

  1. VERSION 4.00
  2. Begin VB.Form PassCheck 
  3.    Appearance      =   0  'Flat
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    ClientHeight    =   2448
  6.    ClientLeft      =   2040
  7.    ClientTop       =   4200
  8.    ClientWidth     =   4668
  9.    BeginProperty Font 
  10.       name            =   "MS Sans Serif"
  11.       charset         =   0
  12.       weight          =   700
  13.       size            =   7.8
  14.       underline       =   0   'False
  15.       italic          =   0   'False
  16.       strikethrough   =   0   'False
  17.    EndProperty
  18.    ForeColor       =   &H80000008&
  19.    Height          =   2772
  20.    Icon            =   "Passchek.frx":0000
  21.    Left            =   1992
  22.    LinkTopic       =   "Form4"
  23.    MaxButton       =   0   'False
  24.    MinButton       =   0   'False
  25.    ScaleHeight     =   2448
  26.    ScaleWidth      =   4668
  27.    ShowInTaskbar   =   0   'False
  28.    Top             =   3924
  29.    Width           =   4764
  30.    Begin VB.TextBox Text1 
  31.       Height          =   360
  32.       Left            =   1704
  33.       TabIndex        =   4
  34.       Top             =   1452
  35.       Width           =   2376
  36.    End
  37.    Begin VB.Timer Timer1 
  38.       Interval        =   30000
  39.       Left            =   120
  40.       Top             =   1680
  41.    End
  42.    Begin VB.CommandButton Command2 
  43.       Appearance      =   0  'Flat
  44.       BackColor       =   &H80000005&
  45.       Cancel          =   -1  'True
  46.       Caption         =   "Cancel"
  47.       Height          =   372
  48.       Left            =   2976
  49.       TabIndex        =   1
  50.       Top             =   1980
  51.       Width           =   1116
  52.    End
  53.    Begin VB.CommandButton Command1 
  54.       Appearance      =   0  'Flat
  55.       BackColor       =   &H80000005&
  56.       Caption         =   "OK"
  57.       Default         =   -1  'True
  58.       Height          =   372
  59.       Left            =   852
  60.       TabIndex        =   0
  61.       Top             =   1980
  62.       Width           =   1104
  63.    End
  64.    Begin VB.Label Label2 
  65.       Appearance      =   0  'Flat
  66.       AutoSize        =   -1  'True
  67.       Caption         =   "Password:"
  68.       BeginProperty Font 
  69.          name            =   "MS Sans Serif"
  70.          charset         =   0
  71.          weight          =   400
  72.          size            =   7.8
  73.          underline       =   0   'False
  74.          italic          =   0   'False
  75.          strikethrough   =   0   'False
  76.       EndProperty
  77.       Height          =   192
  78.       Left            =   720
  79.       TabIndex        =   3
  80.       Top             =   1140
  81.       Width           =   756
  82.    End
  83.    Begin VB.Label Label1 
  84.       BorderStyle     =   1  'Fixed Single
  85.       Caption         =   "The screen saver you are using is password protected.  You must type in the screen saver password to turn off the screen saver."
  86.       BeginProperty Font 
  87.          name            =   "MS Sans Serif"
  88.          charset         =   0
  89.          weight          =   400
  90.          size            =   7.8
  91.          underline       =   0   'False
  92.          italic          =   0   'False
  93.          strikethrough   =   0   'False
  94.       EndProperty
  95.       Height          =   930
  96.       Left            =   600
  97.       TabIndex        =   2
  98.       Top             =   60
  99.       Width           =   3720
  100.    End
  101.    Begin VB.Image Image1 
  102.       BorderStyle     =   1  'Fixed Single
  103.       Height          =   384
  104.       Left            =   60
  105.       Top             =   156
  106.       Width           =   384
  107.    End
  108. Attribute VB_Name = "PassCheck"
  109. Attribute VB_Creatable = False
  110. Attribute VB_Exposed = False
  111. 'For information about this program see the declarations
  112. 'section of the JDSaver.BAS module.
  113. 'This form is the Password form which is displayed at program
  114. 'exit when Password protection is enabled.
  115. Option Explicit
  116. Private Sub Command1_Click()
  117.     Dim CR_LF$
  118.     CR_LF = Chr$(13) + Chr$(10)
  119.     'Test the word entered to see if it matches
  120.     'the preset password
  121.     If encrypt(CStr(text1.Text)) = Password Then
  122.         PassChck = True
  123.     Else
  124.         MsgBox "Incorrect password;" & CR_LF & CR_LF & "Check your screen saver password and try again.", 16, ""
  125.         PassChck = False
  126.     End If
  127.     Unload PassCheck
  128. End Sub
  129. Private Sub Command2_Click()
  130.     'Ignore any entries made and continue with the
  131.     'screen saver.
  132.     PassChck = False
  133.     Unload PassCheck
  134. End Sub
  135. Private Sub Form_Load()
  136.     Dim ret%, x%
  137.     Dim styleFlags&
  138.     'Show the mouse cursor so the user can see where to click
  139.     Do
  140.     Loop Until ShowCursor(True) > 5
  141.     MouseMoves = 0
  142.     Centerform Me
  143.     Image1 = Icon
  144.     'Change the textbox style to show asterisks as characters
  145.     'are entered.
  146.     styleFlags = GetWindowLong(text1.hWnd, GWL_STYLE)
  147.     styleFlags = styleFlags Or ES_PASSWORD
  148.     styleFlags = setWindowLong(text1.hWnd, GWL_STYLE, styleFlags)
  149.     styleFlags = SendMessage(text1.hWnd, EM_SETPASSWORDCHAR, 42, 0&)
  150.     'Make the form TOPMOST, so it will show above the screen saver
  151.     tempLong = SetWindowPos(PassCheck.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
  152. End Sub
  153. Private Sub Form_Paint()
  154.     'Make sure we start with the focus in the textbox
  155.     text1.SetFocus
  156. End Sub
  157. Private Sub Form_Unload(Cancel As Integer)
  158.     'If a valid password has not been entered then we are
  159.     'returning to an operating screen saver, so we need to
  160.     're-hide the mouse cursor.
  161.     If Not PassChck Then
  162.         Do
  163.         Loop Until ShowCursor(False) < -5
  164.     End If
  165. End Sub
  166. Private Sub text1_Change()
  167.     'Reset the timer because there has
  168.     'been user input.
  169.     Timer1.Enabled = False
  170.     Timer1.Enabled = True
  171. End Sub
  172. Private Sub Timer1_Timer()
  173.     'We have a timer set for 30 seconds
  174.     'If there is no user input in that time,
  175.     'close the PassCheck form.
  176.     PassChck = False
  177.     Unload PassCheck
  178. End Sub
  179.