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

  1. VERSION 4.00
  2. Begin VB.Form PassChange 
  3.    Appearance      =   0  'Flat
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "Jim & Don's Screen Saver Password"
  6.    ClientHeight    =   1920
  7.    ClientLeft      =   2556
  8.    ClientTop       =   4056
  9.    ClientWidth     =   5040
  10.    BeginProperty Font 
  11.       name            =   "MS Sans Serif"
  12.       charset         =   0
  13.       weight          =   700
  14.       size            =   7.8
  15.       underline       =   0   'False
  16.       italic          =   0   'False
  17.       strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H80000008&
  20.    Height          =   2244
  21.    HelpContextID   =   5
  22.    Icon            =   "Passchng.frx":0000
  23.    Left            =   2508
  24.    LinkTopic       =   "Form3"
  25.    MaxButton       =   0   'False
  26.    MinButton       =   0   'False
  27.    ScaleHeight     =   1920
  28.    ScaleWidth      =   5040
  29.    ShowInTaskbar   =   0   'False
  30.    Top             =   3780
  31.    Width           =   5136
  32.    Begin VB.TextBox Text3 
  33.       Height          =   300
  34.       Left            =   2760
  35.       TabIndex        =   8
  36.       Top             =   1140
  37.       Width           =   2115
  38.    End
  39.    Begin VB.TextBox Text2 
  40.       Height          =   300
  41.       Left            =   2760
  42.       TabIndex        =   7
  43.       Top             =   720
  44.       Width           =   2115
  45.    End
  46.    Begin VB.TextBox Text1 
  47.       Height          =   300
  48.       Left            =   2760
  49.       TabIndex        =   6
  50.       Top             =   300
  51.       Width           =   2115
  52.    End
  53.    Begin VB.CommandButton Command3 
  54.       Appearance      =   0  'Flat
  55.       BackColor       =   &H80000005&
  56.       Cancel          =   -1  'True
  57.       Caption         =   "Cancel"
  58.       Height          =   324
  59.       Left            =   2724
  60.       TabIndex        =   1
  61.       Top             =   1536
  62.       Width           =   1056
  63.    End
  64.    Begin VB.CommandButton Command1 
  65.       Appearance      =   0  'Flat
  66.       BackColor       =   &H80000005&
  67.       Caption         =   "OK"
  68.       Default         =   -1  'True
  69.       Height          =   336
  70.       Left            =   1248
  71.       TabIndex        =   0
  72.       Top             =   1536
  73.       Width           =   1032
  74.    End
  75.    Begin VB.Label Label3 
  76.       Appearance      =   0  'Flat
  77.       Caption         =   "&Retype New Password:"
  78.       BeginProperty Font 
  79.          name            =   "MS Sans Serif"
  80.          charset         =   0
  81.          weight          =   400
  82.          size            =   7.8
  83.          underline       =   0   'False
  84.          italic          =   0   'False
  85.          strikethrough   =   0   'False
  86.       EndProperty
  87.       ForeColor       =   &H00000000&
  88.       Height          =   240
  89.       Left            =   300
  90.       TabIndex        =   2
  91.       Top             =   1200
  92.       Width           =   2412
  93.    End
  94.    Begin VB.Label Label2 
  95.       Appearance      =   0  'Flat
  96.       Caption         =   "&New Password:"
  97.       BeginProperty Font 
  98.          name            =   "MS Sans Serif"
  99.          charset         =   0
  100.          weight          =   400
  101.          size            =   7.8
  102.          underline       =   0   'False
  103.          italic          =   0   'False
  104.          strikethrough   =   0   'False
  105.       EndProperty
  106.       ForeColor       =   &H00000000&
  107.       Height          =   240
  108.       Left            =   300
  109.       TabIndex        =   3
  110.       Top             =   780
  111.       Width           =   1608
  112.    End
  113.    Begin VB.Label Label1 
  114.       Appearance      =   0  'Flat
  115.       Caption         =   "&Old Password:"
  116.       BeginProperty Font 
  117.          name            =   "MS Sans Serif"
  118.          charset         =   0
  119.          weight          =   400
  120.          size            =   7.8
  121.          underline       =   0   'False
  122.          italic          =   0   'False
  123.          strikethrough   =   0   'False
  124.       EndProperty
  125.       ForeColor       =   &H00000000&
  126.       Height          =   240
  127.       Left            =   300
  128.       TabIndex        =   4
  129.       Top             =   360
  130.       Width           =   1512
  131.    End
  132.    Begin VB.Label Label4 
  133.       Appearance      =   0  'Flat
  134.       AutoSize        =   -1  'True
  135.       Caption         =   "Change Password:"
  136.       BeginProperty Font 
  137.          name            =   "MS Sans Serif"
  138.          charset         =   0
  139.          weight          =   400
  140.          size            =   7.8
  141.          underline       =   0   'False
  142.          italic          =   0   'False
  143.          strikethrough   =   0   'False
  144.       EndProperty
  145.       ForeColor       =   &H00000000&
  146.       Height          =   192
  147.       Left            =   168
  148.       TabIndex        =   5
  149.       Top             =   120
  150.       Width           =   1356
  151.    End
  152. Attribute VB_Name = "PassChange"
  153. Attribute VB_Creatable = False
  154. Attribute VB_Exposed = False
  155. 'For information about this program see the declarations
  156. 'section of the JDSaver.BAS module.
  157. 'This form is used to configure a user's password, used only
  158. 'by this screen saver.  It is is called
  159. 'from Sub Main when the program is started with
  160. 'the /a command parameter
  161. Option Explicit
  162. Private Sub Command1_Click()
  163.     'A character-return/line feed will allow formatting of message boxes.
  164.     Dim CR_LF$
  165.     CR_LF = Chr$(13) + Chr$(10)
  166.     'If a previously entered password exists, the user must enter it to
  167.     'change the password.
  168.     If Password <> "" Then
  169.         If encrypt(CStr(text1.Text)) <> Password Then
  170.             MsgBox "The value for Old Password is not correct." & CR_LF & CR_LF & "Check your screen-saver password, and then try again.", 16, "Change Password"
  171.             text1.Text = ""
  172.             text2.Text = ""
  173.             text3.Text = ""
  174.             text1.SetFocus
  175.         Exit Sub
  176.         End If
  177.     End If
  178.     'Both entries of the new password must match.
  179.     If UCase(text2.Text) <> UCase(text3.Text) Then
  180.         MsgBox "The value for New Password and Retype New Password do not match." & CR_LF & CR_LF & "Try again", 16, "Change Password"
  181.         text1.Text = ""
  182.         text2.Text = ""
  183.         text3.Text = ""
  184.         If Password <> "" Then
  185.             text1.SetFocus
  186.         Else
  187.             text2.SetFocus
  188.         End If
  189.         Exit Sub
  190.     End If
  191.     'Everything matched, so encrypt the new password and store it in
  192.     'the registry.
  193.     Password = encrypt(CStr(text2.Text))
  194.         SaveSetting "Samples", "JD Screen Saver", "Password", Password
  195.     Unload PassChange
  196. End Sub
  197. Private Sub Command3_Click()
  198.     'Ignore everything and exit.
  199.     Unload PassChange
  200. End Sub
  201. Private Sub Form_Load()
  202.     'When the Display Properties sends a "/a command it also passes
  203.     'a handle to its main window.  We can use that to position our
  204.     'form over the top part of the window.
  205.     tempLong = GetWindowRect(CPWindow, CPRect)
  206.     Move (CPRect.Left * xPixel) + (((CPRect.Right - CPRect.Left) * xPixel) - Width) / 2, (CPRect.Top + 60) * yPixel
  207.     'Change the style of the text boxes to show asterisks as characters
  208.     'are entered.
  209.     Dim styleFlags&
  210.     styleFlags = GetWindowLong(text1.hWnd, GWL_STYLE)
  211.     styleFlags = styleFlags Or ES_PASSWORD
  212.     styleFlags = setWindowLong(text1.hWnd, GWL_STYLE, styleFlags)
  213.     styleFlags = SendMessage(text1.hWnd, EM_SETPASSWORDCHAR, 42, 0&)
  214.     styleFlags = GetWindowLong(text2.hWnd, GWL_STYLE)
  215.     styleFlags = styleFlags Or ES_PASSWORD
  216.     styleFlags = setWindowLong(text2.hWnd, GWL_STYLE, styleFlags)
  217.     styleFlags = SendMessage(text2.hWnd, EM_SETPASSWORDCHAR, 42, 0&)
  218.     styleFlags = GetWindowLong(text3.hWnd, GWL_STYLE)
  219.     styleFlags = styleFlags Or ES_PASSWORD
  220.     styleFlags = setWindowLong(text3.hWnd, GWL_STYLE, styleFlags)
  221.     styleFlags = SendMessage(text3.hWnd, EM_SETPASSWORDCHAR, 42, 0&)
  222.     'Get any previously saved password
  223.     Password = GetSetting("Samples", "JD Screen Saver", "Password")
  224.     'If there is not a previous password, we will disable the "old
  225.     'password" text box
  226.     If Password = "" Then
  227.         label1.ForeColor = vb3DShadow
  228.         text1.Enabled = False
  229.     End If
  230. End Sub
  231. Private Sub Form_Paint()
  232.     Static Painted%
  233.     If Painted Then
  234.         Exit Sub
  235.     End If
  236.     Painted = True
  237.     'Set the initial focus
  238.     If text1.Enabled Then
  239.         text1.SetFocus
  240.     Else
  241.         text2.SetFocus
  242.     End If
  243. End Sub
  244.