📄 frmlogin.frm
字号:
VERSION 5.00
Begin VB.Form frmLogin
BorderStyle = 1 'Fixed Single
Caption = "Login"
ClientHeight = 3735
ClientLeft = 2835
ClientTop = 3480
ClientWidth = 3735
Icon = "frmLogin.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2206.761
ScaleMode = 0 'User
ScaleWidth = 3506.963
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton cmdok
Appearance = 0 'Flat
Height = 375
Left = 840
Picture = "frmLogin.frx":0442
Style = 1 'Graphical
TabIndex = 6
Top = 3240
Width = 1095
End
Begin VB.PictureBox picLogo
AutoRedraw = -1 'True
AutoSize = -1 'True
BackColor = &H00800000&
BorderStyle = 0 'None
Height = 1770
Left = 840
Picture = "frmLogin.frx":0B14
ScaleHeight = 118
ScaleMode = 3 'Pixel
ScaleWidth = 140
TabIndex = 5
TabStop = 0 'False
ToolTipText = "Show Users"
Top = 120
Width = 2100
End
Begin VB.Data datsettings
Caption = "Data1"
Connect = "Access"
DatabaseName = "C:\LIBRARY\Library.mdb"
DefaultCursorType= 0 'DefaultCursor
DefaultType = 2 'UseODBC
Exclusive = 0 'False
Height = 375
Left = 0
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "Settings"
Top = 1320
Visible = 0 'False
Width = 1140
End
Begin VB.TextBox txtUserName
Height = 345
Left = 1290
TabIndex = 1
Top = 2280
Width = 2325
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "Cancel"
Height = 390
Left = 2100
TabIndex = 4
Top = 3240
Width = 1140
End
Begin VB.TextBox txtPassword
Height = 345
IMEMode = 3 'DISABLE
Left = 1290
PasswordChar = "*"
TabIndex = 3
Top = 2685
Width = 2325
End
Begin VB.Line Line1
X1 = 112.674
X2 = 3380.205
Y1 = 1205.299
Y2 = 1205.299
End
Begin VB.Label lblLabels
Caption = "&User Name:"
Height = 270
Index = 0
Left = 105
TabIndex = 0
Top = 2310
Width = 1080
End
Begin VB.Label lblLabels
Caption = "&Password:"
Height = 270
Index = 1
Left = 105
TabIndex = 2
Top = 2700
Width = 1080
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public password As String, username As String
Public LoginSucceeded As Boolean, mycolor As String, returncolor As String
Private Declare Function DrawEdge Lib "user32" (ByVal hdc As Long, qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Const BF_TOP = &H2
Private Const BF_RIGHT = &H4
Private Const BF_LEFT = &H1
Private Const BF_BOTTOM = &H8
Private Const BF_RECT = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM)
Private Const BF_SOFT = &H1000
Public Enum m_BorderType
BDR_INNER = &HC
BDR_OUTER = &H3
BDR_RAISED = &H5
BDR_RAISEDINNER = &H4
BDR_RAISEDOUTER = &H1
BDR_SUNKEN = &HA
BDR_SUNKENINNER = &H8
BDR_SUNKENOUTER = &H2
EDGE_BUMP = (BDR_RAISEDOUTER Or BDR_SUNKENINNER)
EDGE_ETCHED = (BDR_SUNKENOUTER Or BDR_RAISEDINNER)
EDGE_RAISED = (BDR_RAISEDOUTER Or BDR_RAISEDINNER)
EDGE_SUNKEN = (BDR_SUNKENOUTER Or BDR_SUNKENINNER)
End Enum
Private intWidth As Integer '//form's width
Private intHeight As Integer '//form's height
Private Sub DrawBorders(theObject As Object, Border As m_BorderType)
Dim rct As RECT
rct.Left = theObject.ScaleLeft
rct.Top = theObject.ScaleTop
rct.Bottom = theObject.ScaleHeight
rct.Right = theObject.ScaleWidth
DrawEdge theObject.hdc, rct, Border Or BF_SOFT, BF_RECT
End Sub
Private Sub Form_Load()
DrawBorders picLogo, EDGE_RAISED
DrawBorders Me, EDGE_ETCHED
'MDIForm1.Show
'MDIForm1.mnufile.Enabled = False
'MDIForm1.mnuhelper.Enabled = False
'MDIForm1.mnureports.Enabled = False
'MDIForm1.mnulibrary.Enabled = False
End Sub
Private Sub picLogo_Click()
frmUsers.Show
End Sub
Private Sub picLogo_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
picLogo.Cls
DrawBorders picLogo, BDR_SUNKEN
End Sub
Private Sub picLogo_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
picLogo.Cls
DrawBorders picLogo, EDGE_RAISED
End Sub
Private Sub cmdcancel_Click()
'set the global var to false
'to denote a failed login
LoginSucceeded = False
frmLogin.Hide
Unload frmLogin
End Sub
Private Sub cmdok_Click()
'check for correct password and if correct then grant access to the application
If txtPassword = password And txtUserName = username Then
LoginSucceeded = True
Unload Me
MDIForm1.Show
' mdilibrary.Enabled = True
' With mdilibrary
'MDIForm1.mnufile.Enabled = True
'MDIForm1.mnulibrary.Enabled = True
'MDIForm1.mnureports.Enabled = True
'MDIForm1.mnuhelper.Enabled = True
'End With
Load frmDefault
frmDefault.Show
Unload frmLogin
Else
MsgBox "Invalid Password, try again!", , "Login"
txtUserName.SetFocus
SendKeys "{Home}+{End}"
End If
'Dim a As String, b As String, c As String, d As String, e As String
'a = datsettings.Recordset.Fields("mdi")
'mycolor = a
'mdilibrary.BackColor = a
'b = datsettings.Recordset.Fields("borrowing")
'mycolor = b
'frmborrowing.BackColor = mycolor
'c = datsettings.Recordset.Fields("returning")
'mycolor = c
'frmreturning.BackColor = mycolor
'd = datsettings.Recordset.Fields("userdetails")
'mycolor = d
'frmBookinfo.BackColor = mycolor
'e = datsettings.Recordset.Fields("bookinfo")
'mycolor = e
'frmuserparticulars.BackColor = mycolor
End Sub
Private Sub Form_Activate()
'denying access to the menus for the user to acces
'With mdilibrary
'.mnufile.disabled = False
'.mnusettings.disabled = False
'.mnulibrary.disabled = False
'.Mnuwindow.disabled = False
'.mnuhelp.disabled = False
'End With
username = datsettings.Recordset.Fields("UserName")
password = datsettings.Recordset.Fields("Password")
'txtUserName.Text = username
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -