home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Game Programming for Teens / VBGPFT.cdr / DirectX8 / dx8vbsdk.exe / samples / multimedia / vbsamples / directplay / dxvbmessenger / client / frmlogin.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2000-10-02  |  6.5 KB  |  183 lines

  1. VERSION 5.00
  2. Begin VB.Form frmLogin 
  3.    BorderStyle     =   4  'Fixed ToolWindow
  4.    Caption         =   "Login"
  5.    ClientHeight    =   3255
  6.    ClientLeft      =   45
  7.    ClientTop       =   285
  8.    ClientWidth     =   4680
  9.    Icon            =   "frmLogin.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   3255
  14.    ScaleWidth      =   4680
  15.    ShowInTaskbar   =   0   'False
  16.    StartUpPosition =   1  'CenterOwner
  17.    Begin VB.CommandButton cmdCancel 
  18.       Cancel          =   -1  'True
  19.       Caption         =   "Cancel"
  20.       Height          =   375
  21.       Left            =   2520
  22.       TabIndex        =   5
  23.       Top             =   2760
  24.       Width           =   1035
  25.    End
  26.    Begin VB.CommandButton cmdCreate 
  27.       Caption         =   "&Create Account"
  28.       Height          =   375
  29.       Left            =   60
  30.       TabIndex        =   4
  31.       Top             =   2760
  32.       Width           =   1335
  33.    End
  34.    Begin VB.CommandButton cmdLogin 
  35.       Caption         =   "Log on"
  36.       Default         =   -1  'True
  37.       Height          =   375
  38.       Left            =   3600
  39.       TabIndex        =   6
  40.       Top             =   2760
  41.       Width           =   1035
  42.    End
  43.    Begin VB.TextBox txtServerName 
  44.       Height          =   285
  45.       Left            =   60
  46.       TabIndex        =   3
  47.       Top             =   2400
  48.       Width           =   4515
  49.    End
  50.    Begin VB.CheckBox chkRemember 
  51.       Caption         =   "Remember this password"
  52.       Height          =   255
  53.       Left            =   60
  54.       TabIndex        =   2
  55.       Top             =   1860
  56.       Width           =   4515
  57.    End
  58.    Begin VB.TextBox txtPassword 
  59.       Height          =   285
  60.       IMEMode         =   3  'DISABLE
  61.       Left            =   60
  62.       PasswordChar    =   "*"
  63.       TabIndex        =   1
  64.       Top             =   1500
  65.       Width           =   4515
  66.    End
  67.    Begin VB.TextBox txtUserName 
  68.       Height          =   285
  69.       Left            =   60
  70.       TabIndex        =   0
  71.       Top             =   900
  72.       Width           =   4515
  73.    End
  74.    Begin VB.Label Label1 
  75.       BackStyle       =   0  'Transparent
  76.       Caption         =   "Server Name:"
  77.       Height          =   195
  78.       Index           =   3
  79.       Left            =   60
  80.       TabIndex        =   10
  81.       Top             =   2160
  82.       Width           =   1395
  83.    End
  84.    Begin VB.Label Label1 
  85.       BackStyle       =   0  'Transparent
  86.       Caption         =   "Password:"
  87.       Height          =   195
  88.       Index           =   2
  89.       Left            =   60
  90.       TabIndex        =   9
  91.       Top             =   1260
  92.       Width           =   915
  93.    End
  94.    Begin VB.Label Label1 
  95.       BackStyle       =   0  'Transparent
  96.       Caption         =   "UserName:"
  97.       Height          =   195
  98.       Index           =   1
  99.       Left            =   60
  100.       TabIndex        =   8
  101.       Top             =   660
  102.       Width           =   915
  103.    End
  104.    Begin VB.Label Label1 
  105.       BackStyle       =   0  'Transparent
  106.       Caption         =   "Please type in your username, password and server to connect to, or click the 'Create Account' button..."
  107.       Height          =   495
  108.       Index           =   0
  109.       Left            =   60
  110.       TabIndex        =   7
  111.       Top             =   120
  112.       Width           =   4575
  113.    End
  114. Attribute VB_Name = "frmLogin"
  115. Attribute VB_GlobalNameSpace = False
  116. Attribute VB_Creatable = False
  117. Attribute VB_PredeclaredId = True
  118. Attribute VB_Exposed = False
  119. Option Explicit
  120. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  121. '  Copyright (C) 2000 Microsoft Corporation.  All Rights Reserved.
  122. '  File:       frmLogin.frm
  123. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  124. Private Sub cmdCancel_Click()
  125.     Unload Me
  126. End Sub
  127. Private Sub cmdCreate_Click()
  128.     Unload Me
  129.     frmCreate.Show , frmClient
  130. End Sub
  131. Private Sub cmdLogin_Click()
  132.     Dim AppDesc As DPN_APPLICATION_DESC
  133.     gfCreatePlayer = False
  134.     If txtServerName.Text = vbNullString Then 'They didn't enter a server name
  135.         MsgBox "You must enter a server name.", vbOKOnly Or vbInformation, "No server name."
  136.         Exit Sub
  137.     End If
  138.     If txtPassword.Text = vbNullString Then 'They didn't enter a password
  139.         MsgBox "You must enter a password.", vbOKOnly Or vbInformation, "No password."
  140.         Exit Sub
  141.     End If
  142.     If txtUserName.Text = vbNullString Then 'They didn't enter a user name
  143.         MsgBox "You must enter a user name.", vbOKOnly Or vbInformation, "No user name."
  144.         Exit Sub
  145.     End If
  146.     'Now let's save the settings
  147.     SaveSetting gsAppName, "Startup", "ServerName", txtServerName.Text
  148.     SaveSetting gsAppName, "Startup", "Username", txtUserName.Text
  149.     If chkRemember.Value = vbChecked Then
  150.         SaveSetting gsAppName, "Startup", "Password", txtPassword.Text
  151.     Else
  152.         SaveSetting gsAppName, "Startup", "Password", vbNullString
  153.     End If
  154.     If gsServerName = vbNullString Then gsServerName = txtServerName.Text
  155.     If gfConnected And (gsServerName = txtServerName.Text) Then
  156.         'Save the username/password
  157.         gsPass = EncodePassword(txtPassword.Text, glClientSideEncryptionKey)
  158.         gsUserName = txtUserName.Text
  159.         LogonPlayer
  160.     Else
  161.         If gfConnected Then
  162.             InitDPlay 'Re-Initialize DPlay
  163.         End If
  164.         dpas.AddComponentString DPN_KEY_HOSTNAME, txtServerName.Text 'We only want to connect on this host
  165.         'First set up our application description
  166.         With AppDesc
  167.             .guidApplication = AppGuid
  168.         End With
  169.         'Save the username/password
  170.         gsPass = EncodePassword(txtPassword.Text, glClientSideEncryptionKey)
  171.         gsUserName = txtUserName.Text
  172.         'Try to connect to this server
  173.         dpc.Connect AppDesc, dpas, dpa, 0, ByVal 0&, 0
  174.     End If
  175. End Sub
  176. Private Sub Form_Load()
  177.     'First retrieve the settings
  178.     txtServerName.Text = GetSetting(gsAppName, "Startup", "ServerName", vbNullString)
  179.     txtUserName.Text = GetSetting(gsAppName, "Startup", "Username", vbNullString)
  180.     txtPassword.Text = GetSetting(gsAppName, "Startup", "Password", vbNullString)
  181.     If txtPassword.Text <> vbNullString Then chkRemember.Value = vbChecked 'We remembered our password
  182. End Sub
  183.