📄 frmlogin.frm
字号:
VERSION 5.00
Begin VB.Form frmlogin
BorderStyle = 0 'None
Caption = "登录"
ClientHeight = 7680
ClientLeft = 0
ClientTop = -105
ClientWidth = 9555
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 7680
ScaleWidth = 9555
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.PictureBox Picture1
Height = 8535
Left = -120
Picture = "frmlogin.frx":0000
ScaleHeight = 8475
ScaleWidth = 10155
TabIndex = 0
Top = 0
Width = 10215
Begin VB.TextBox Txtpwd
Height = 375
IMEMode = 3 'DISABLE
Left = 6000
PasswordChar = "*"
TabIndex = 2
Top = 4200
Width = 2295
End
Begin VB.TextBox Txtuser
Height = 375
Left = 6000
TabIndex = 1
Top = 3240
Width = 2295
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Height = 495
Left = 9120
MouseIcon = "frmlogin.frx":FBAA
MousePointer = 99 'Custom
TabIndex = 6
Top = 240
Width = 495
End
Begin VB.Label Lblzhucu
BackStyle = 0 'Transparent
Height = 615
Left = 6360
MouseIcon = "frmlogin.frx":FCFC
MousePointer = 99 'Custom
TabIndex = 5
Top = 6720
Width = 615
End
Begin VB.Label Lblquxiao
BackStyle = 0 'Transparent
Height = 735
Left = 7200
MouseIcon = "frmlogin.frx":FE4E
MousePointer = 99 'Custom
TabIndex = 4
Top = 6480
Width = 855
End
Begin VB.Label lbldenglu
BackStyle = 0 'Transparent
Height = 975
Left = 8400
MouseIcon = "frmlogin.frx":FFA0
MousePointer = 99 'Custom
TabIndex = 3
Top = 6240
Width = 975
End
End
End
Attribute VB_Name = "frmlogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Download by http://www.codefans.net
Option Explicit
Dim cnt As Integer '记录确定次数
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const RGN_XOR = 3
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Private Type RECT
left As Long
top As Long
right As Long
bottom As Long
End Type
Dim Xs As Long
Function CreatePictureform()
On Error Resume Next
Dim hRgn As Long, hRect As RECT, hTempRgn As Long, tColour As Long, OldScaleMode As Integer, AbsoluteX As Long, AbsoluteY As Long
Dim Color As Long, Hrect1 As RECT
Dim xx As Long, yy As Long
Dim rtn As Long
Me.Picture = Me.Picture1
Me.Width = Me.Picture1.Width
Me.Height = Me.Picture1.Height
OldScaleMode = Me.ScaleMode
Me.AutoRedraw = True
Me.ScaleMode = 3
Color = vbWhite
rtn = GetWindowRect(Me.hwnd, hRect)
hRgn = CreateRectRgn(0, 0, hRect.right, hRect.bottom)
For AbsoluteX = 0 To Me.ScaleWidth
For AbsoluteY = 0 To Me.ScaleHeight
tColour = GetPixel(Me.hdc, AbsoluteX, AbsoluteY)
If tColour = Color Then
hTempRgn = CreateRectRgn(AbsoluteX, AbsoluteY, AbsoluteX + 1, AbsoluteY + 1)
rtn = CombineRgn(hRgn, hRgn, hTempRgn, RGN_XOR)
rtn = DeleteObject(hTempRgn)
End If
Next AbsoluteY
Next AbsoluteX
rtn = SetWindowRgn(Me.hwnd, hRgn, True)
DeleteObject hRgn
Me.ScaleMode = OldScaleMode
If Err Then
MsgBox Error, 16, Err
End If
End Function
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Dim ReturnVal As Long
Xs = ReleaseCapture()
ReturnVal = SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub
Private Sub Form_Load()
Dim connectionstring As String
connectionstring = "provider=Microsoft.Jet.oledb.4.0;" & _
"Data Source=medic.mdb"
conn.Open connectionstring
cnt = 0
End Sub
Private Sub lbldenglu_Click()
Dim sql As String
Dim rs_login As New ADODB.Recordset
If Trim(Txtuser.Text) = "" Then '判断输入的用户名是否为空
MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
Txtuser.SetFocus
Else
sql = "select * from 系统管理 where 用户名='" & Txtuser.Text & "'"
rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_login.EOF = True Then
MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
Txtuser.SetFocus
Else '检验密码是否正确
If Trim(rs_login.Fields(1)) = Trim(Txtpwd.Text) And Trim(rs_login.Fields(2)) = "system" Then
userID = Txtuser.Text
userpow = rs_login.Fields(2)
rs_login.Close
Unload Me
Main.Show
ElseIf Trim(rs_login.Fields(1)) = Trim(Txtpwd.Text) And Trim(rs_login.Fields(2)) = "guest" Then
userpow = rs_login.Fields(2)
rs_login.Close
Unload Me
Main.Show
Main.Menu_Edit.Enabled = False
Main.Menu_ManageAdd.Enabled = False
Else
MsgBox "密码不正确", vbOKOnly + vbExclamation, ""
Txtpwd.SetFocus
End If
End If
End If
cnt = cnt + 1
If cnt = 3 Then
Unload Me
End If
Exit Sub
End Sub
Private Sub Txtpwd_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Dim sql As String
Dim rs_login As New ADODB.Recordset
If Trim(Txtuser.Text) = "" Then '判断输入的用户名是否为空
MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
Txtuser.SetFocus
Else
sql = "select * from 系统管理 where 用户名='" & Txtuser.Text & "'"
rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_login.EOF = True Then
MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
Txtuser.SetFocus
Else '检验密码是否正确
If Trim(rs_login.Fields(1)) = Trim(Txtpwd.Text) And Trim(rs_login.Fields(2)) = "system" Then
userID = Txtuser.Text
userpow = rs_login.Fields(2)
rs_login.Close
Unload Me
Main.Show
ElseIf Trim(rs_login.Fields(1)) = Trim(Txtpwd.Text) And Trim(rs_login.Fields(2)) = "guest" Then
userpow = rs_login.Fields(2)
rs_login.Close
Unload Me
Main.Show
Main.Menu_Edit.Enabled = False
Main.Menu_ManageAdd.Enabled = False
Else
MsgBox "密码不正确", vbOKOnly + vbExclamation, ""
Txtpwd.SetFocus
End If
End If
End If
cnt = cnt + 1
If cnt = 3 Then
Unload Me
End If
End If
Exit Sub
End Sub
Private Sub Lblquxiao_Click()
End
End Sub
Private Sub Lblzhucu_Click()
Unload Me
frmadduser.Show
End Sub
Private Sub Label1_Click()
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -