📄 frmbackground.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
Object = "{0B81E4A9-BE4E-4AEF-9272-33AB5B51C6FC}#1.0#0"; "XPControls.ocx"
Begin VB.Form frmBackground
BackColor = &H80000018&
BorderStyle = 1 'Fixed Single
Caption = "背景设置"
ClientHeight = 6240
ClientLeft = 45
ClientTop = 435
ClientWidth = 5835
Icon = "frmBackground.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 6240
ScaleWidth = 5835
StartUpPosition = 1 '所有者中心
Begin XPControls.XPCommandButton cmdBrowser
Height = 435
Left = 3990
TabIndex = 4
Top = 4230
Width = 1125
_ExtentX = 1984
_ExtentY = 767
Caption = "浏览...(&B)"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin XPControls.XPCommandButton cmdOK
Height = 435
Left = 930
TabIndex = 1
Top = 5610
Width = 1125
_ExtentX = 1984
_ExtentY = 767
Caption = "确定(&O)"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin XPControls.XPCommandButton cmdCancel
Cancel = -1 'True
Height = 435
Left = 2460
TabIndex = 2
Top = 5610
Width = 1125
_ExtentX = 1984
_ExtentY = 767
Caption = "取消(&C)"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin XPControls.XPCommandButton cmdApply
Height = 435
Left = 3990
TabIndex = 3
Top = 5610
Width = 1125
_ExtentX = 1984
_ExtentY = 767
Caption = "应用(&A)"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 4350
Top = 3540
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.ListBox lstFileName
Height = 1680
Left = 450
TabIndex = 0
Top = 3510
Width = 3165
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "背景:"
Height = 195
Left = 450
TabIndex = 5
Top = 3270
Width = 540
End
Begin VB.Image imgBackground
BorderStyle = 1 'Fixed Single
Height = 2985
Left = 450
Stretch = -1 'True
Top = 180
Width = 4935
End
End
Attribute VB_Name = "frmBackground"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdApply_Click()
On Error GoTo ErrMsg
Dim Status
Dim strSQL As String
Dim cmd As New ADODB.Command
gstrManagerBackground = lstFileName.Text
fMainForm.SetBackground
cmdApply.Enabled = False
strSQL = "update RY_Employee set Background='" _
& lstFileName.Text & "' where Name='" & gstrManagerName & "'"
Set cmd.ActiveConnection = GCon
cmd.CommandText = strSQL
cmd.Execute
gstrManagerBackground = lstFileName.Text
'添加到日志
' AddLog gstrManagerName, "设置背景", OperationLog
Exit Sub
ErrMsg:
Status = SetError(Err.Number, Err.Description, Me.Caption & ".cmdApply_Click")
ErrMsg Status
End Sub
Private Sub cmdApply_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
ShowStatus "应用"
End Sub
Private Sub cmdBrowser_Click()
On Error Resume Next
Dim strFileName As String
With CommonDialog1
.DialogTitle = "请选择图片文件"
.CancelError = True
.Filter = "位图(*.bmp)和GPEG(*.jpg)|*.bmp;*.jpg|位图(*.bmp)|*.bmp" _
& "|GPEG(*.jpg)|*.jpg|GIF(*.gif)|*.gif|图标(*.ico)|*.ico" _
& "|DIB(*.dib)|*.dib|JPE(*.jpe)|*.jpe|TIF(*.tif)|*.tif" _
& "|PNG(*.png)|*.png" _
& "|所有图片文件|*.bmp;*.jpg;*.gif;*.ico;*.dib;*.jpe;*.tif;*.png"
.ShowOpen
If Err.Number <> cdlCancel Then
strFileName = .FileName
FileCopy strFileName, gstrCurrPath & BackgroundDir & GetFileName(strFileName)
lstFileName.AddItem GetFileName(strFileName)
lstFileName.ListIndex = lstFileName.NewIndex
cmdApply.Enabled = True
End If
End With
End Sub
Private Sub cmdBrowser_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
ShowStatus "浏览电脑上的图片"
End Sub
Private Sub cmdCancel_Click()
Me.Hide
Unload Me
End Sub
Private Sub cmdCancel_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
ShowStatus "取消"
End Sub
Private Sub cmdOK_Click()
If cmdApply.Enabled = True Then
cmdApply_Click
End If
cmdCancel_Click
End Sub
Private Sub cmdOK_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
ShowStatus "确定"
End Sub
Private Sub Form_Load()
On Error GoTo ErrMsg
Dim strStatus
Dim fso As FileSystemObject
Dim fld As Folder
Dim filTemp As File
Dim strExtendName As String
Set fso = New FileSystemObject
Set fld = fso.GetFolder(gstrCurrPath & BackgroundDir)
lstFileName.AddItem "(无)"
If gstrManagerBackground = "(无)" Then
lstFileName.ListIndex = lstFileName.NewIndex
End If
For Each filTemp In fld.Files
strExtendName = LCase(Right(filTemp, 4))
If strExtendName = ".bmp" _
Or strExtendName = ".jpg" _
Or strExtendName = ".gif" _
Or strExtendName = ".ico" _
Or strExtendName = ".dib" _
Or strExtendName = "jpeg" _
Or strExtendName = ".jpe" _
Or strExtendName = ".tif" _
Or strExtendName = ".png" Then
lstFileName.AddItem filTemp.name
If filTemp.name = gstrManagerBackground Then
lstFileName.ListIndex = lstFileName.NewIndex
End If
End If
Next
If lstFileName.Text = "" Then
lstFileName.AddItem GetFileName(gstrManagerBackground)
lstFileName.ListIndex = lstFileName.NewIndex
End If
cmdApply.Enabled = False
Exit Sub
ErrMsg:
strStatus = SetError(Err.Number, Err.Description, Me.Caption & ".Form_Load")
ErrMsg strStatus
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
ShowStatus "Ready"
End Sub
Private Sub Form_Unload(Cancel As Integer)
ShowStatus "Ready"
' Me.Hide
' Set frmBackground = Nothing
End Sub
Private Sub imgBackground_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
ShowStatus "背景预览"
End Sub
Private Sub lstFileName_Click()
On Error Resume Next
If cmdApply.Enabled = False Then cmdApply.Enabled = True
If lstFileName.Text = "(无)" Then
Set imgBackground.PICTURE = Nothing
Else
Set imgBackground.PICTURE = LoadPicture(gstrCurrPath & BackgroundDir & lstFileName.Text)
End If
End Sub
'Purpose: Get file name according to all path
Private Function GetFileName(ByVal strFileName As String) As String
On Error GoTo ErrMsg
Dim i As Integer
GetFileName = ""
For i = Len(strFileName) To 1 Step -1
If Mid(strFileName, i, 1) = "\" Then Exit For
Next i
GetFileName = Mid(strFileName, i + 1)
Exit Function
ErrMsg:
'
End Function
Private Sub lstFileName_DblClick()
cmdApply_Click
End Sub
Private Sub lstFileName_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdApply_Click
End If
End Sub
Private Sub lstFileName_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
ShowStatus "背景文件名"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -