⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmlogin.frm

📁 用VB6.0编写的QQ聊天软件
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form frmLogin 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "管理员登录"
   ClientHeight    =   2040
   ClientLeft      =   2835
   ClientTop       =   3480
   ClientWidth     =   3015
   ClipControls    =   0   'False
   DrawMode        =   1  'Blackness
   FillStyle       =   0  'Solid
   BeginProperty Font 
      Name            =   "宋体"
      Size            =   9
      Charset         =   134
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   FontTransparent =   0   'False
   HasDC           =   0   'False
   Icon            =   "frmLogin.frx":0000
   MaxButton       =   0   'False
   MinButton       =   0   'False
   NegotiateMenus  =   0   'False
   ScaleHeight     =   136
   ScaleMode       =   0  'User
   ScaleWidth      =   201
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   Begin MSComctlLib.ImageCombo cboUserName 
      CausesValidation=   0   'False
      Height          =   315
      Left            =   960
      TabIndex        =   1
      Top             =   240
      Width           =   1815
      _ExtentX        =   3201
      _ExtentY        =   556
      _Version        =   393216
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      Locked          =   -1  'True
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "登录"
      Default         =   -1  'True
      Height          =   375
      Left            =   600
      TabIndex        =   4
      Top             =   1440
      Width           =   900
   End
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "退出"
      Height          =   375
      Left            =   1560
      TabIndex        =   5
      Top             =   1440
      Width           =   900
   End
   Begin VB.TextBox txtPassword 
      Height          =   300
      IMEMode         =   3  'DISABLE
      Left            =   960
      PasswordChar    =   "*"
      TabIndex        =   3
      Top             =   960
      Width           =   1845
   End
   Begin VB.Label lblLabels 
      Alignment       =   1  'Right Justify
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "管理员"
      Height          =   180
      Index           =   0
      Left            =   300
      TabIndex        =   0
      Top             =   420
      Width           =   540
   End
   Begin VB.Label lblLabels 
      Alignment       =   1  'Right Justify
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "密码"
      Height          =   180
      Index           =   1
      Left            =   480
      TabIndex        =   2
      Top             =   1020
      Width           =   360
   End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private tkErr As Byte

Private Sub cmdCancel_Click()
    Unload Me
    Unload frmMain
End Sub

Private Sub cmdOK_Click()
    If rst.State = adStateOpen Then rst.Close
    rst.Open "管理员", cnn, adOpenKeyset, adLockReadOnly, adCmdTable
    rst.Move cboUserName.SelectedItem.Index - 1
    If cboUserName.Text = rst!昵称 And txtPassword.Text = rst!密码 Then
        tkPower = rst!权限
        Unload Me
        Unload frmMain
        tkLogin = False
        frmMain.Show
    Else
        If tkErr < 2 Then
            MsgBox "密码错误,请输入正确的密码!", vbCritical, "警告"
            txtPassword.Text = vbNullString
            txtPassword.SetFocus
            tkErr = tkErr + 1
        Else
            MsgBox "密码错误不得超过三次,否则视您为非法用户!", vbCritical, "警告"
            Unload Me
            Unload frmMain
        End If
    End If
End Sub

Private Sub Form_Activate()
    txtPassword.SetFocus
End Sub

Private Sub Form_Load()
    ' 删除系统关闭菜单
    Dim tkSystemMenu As Long
    Dim tkSystemMenuItemCount As Long
    
    ' 标志正在登录
    tkLogin = True
    
    tkSystemMenu = GetSystemMenu(Me.hwnd, 0)
    tkSystemMenuItemCount = GetMenuItemCount(tkSystemMenu)
    RemoveMenu tkSystemMenu, tkSystemMenuItemCount - 1, MF_BYPOSITION
    RemoveMenu tkSystemMenu, tkSystemMenuItemCount - 2, MF_BYPOSITION
    
    ' 将窗体设为最前
    SetWindowPos Me.hwnd, _
        HWND_TOPMOST, _
        Me.Left, _
        Me.Top, _
        Me.Width \ Screen.TwipsPerPixelX, _
        Me.Height \ Screen.TwipsPerPixelY, _
        0
    
    With rst
        If .State = adStateOpen Then .Close
        .Open "管理员", cnn, adOpenKeyset, adLockOptimistic, adCmdTable
        If .RecordCount = 0 Then
            .AddNew
            !标识 = "10000"
            !昵称 = "铁拳"
            !密码 = "tekken"
            !头像 = 15
            !性别 = "男"
            !权限 = 1
            .Update
            .Close

            .Open "管理员资料", cnn, adOpenKeyset, adLockOptimistic, adCmdTable
            .AddNew
            !标识 = "10000"
            .Update
        End If
    End With
    
    If rst.State = adStateOpen Then rst.Close
    rst.Open "管理员", cnn, adOpenKeyset, adLockReadOnly, adCmdTable

    cboUserName.ImageList = frmMain.imgLstFaces
    While Not rst.EOF
        cboUserName.ComboItems.Add , , rst!昵称, Val(rst!头像)
        rst.MoveNext
    Wend
    cboUserName.ComboItems(1).Selected = True
End Sub

Private Sub txtPassword_GotFocus()
    txtPassword.SelStart = 0
    txtPassword.SelLength = Len(txtPassword.Text)
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -