📄 form1.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
Caption = "屏幕抓图"
ClientHeight = 4500
ClientLeft = 60
ClientTop = 345
ClientWidth = 6240
LinkTopic = "Form2"
ScaleHeight = 4500
ScaleWidth = 6240
StartUpPosition = 1 '所有者中心
Begin MSComDlg.CommonDialog CommonDialog1
Left = 225
Top = 2295
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Command2
Caption = "另存为"
Height = 390
Left = 2265
TabIndex = 2
Top = 3960
Width = 1650
End
Begin VB.CommandButton Command3
Caption = "退出"
Height = 390
Left = 4185
TabIndex = 1
Top = 3960
Width = 1650
End
Begin VB.CommandButton Command1
Caption = "捕捉"
Height = 390
Left = 390
TabIndex = 0
Top = 3960
Width = 1650
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function EmptyClipboard Lib "user32" () As Long
Private Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, _
ByVal hMem As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, _
ByVal hObject As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, _
ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, _
ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, _
ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, _
ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As Long) As Long
Private Sub Command1_Click()
Me.Visible = False
SourceDC = CreateDC("DISPLAY", 0, 0, 0)
DestDC = CreateCompatibleDC(SourceDC)
Bhandle = CreateCompatibleBitmap(SourceDC, 800, 600)
SelectObject DestDC, Bhandle
BitBlt DestDC, 0, 0, 800, 600, SourceDC, 0, 0, &HCC0020
Wnd = Screen.ActiveForm.hwnd
OpenClipboard Wnd
EmptyClipboard
SetClipboardData 2, Bhandle
CloseClipboard
DeleteDC DestDC
ReleaseDC Dhandle, SourceDC
Me.Picture = Clipboard.GetData()
Me.Visible = True
End Sub
Private Sub Command2_Click()
Me.Picture = Me.Image
'保存捕捉的图片
CommonDialog1.Filter = "BMP文件(*.bmp)|*.bmp|JPG文件(*.jpg)|*.jpg"
CommonDialog1.ShowSave
CommonDialog1.Flags = &H2 + &H4 + &H8
If CommonDialog1.FileName <> "" Then
SavePicture Me.Picture, CommonDialog1.FileName
End If
End Sub
Private Sub Command3_Click()
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -