Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd 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 GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hDc As Long) As Long
Private Sub Command1_Click()
Dim hDc As Long
Form1.Hide
DoEvents '若不执行这一句,则me.hide不会即时被执行
PicCopy.Width = Screen.Width
PicCopy.Height = Screen.Height
PicCopy.AutoRedraw = True
hDc = GetDC(0) '取得屏幕DC
'将屏幕DC的图象转移到名称为PicCopy 的picturebox中
BitBlt PicCopy.hDc, 0, 0, Screen.Width \ Screen.TwipsPerPixelX, Screen.Width \ Screen.TwipsPerPixelY, GetWindowDC(0), 0, 0, SRCCOPY
SavePicture PicCopy.Image, "e:\abc.bmp" '保存图象到一个名为abc的bmp文件中
ReleaseDC 0, hDc '释放屏幕DC
Me.Show
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货