VB 版 (精华区)
发信人: zxfsnow (希望的春天), 信区: VB
标 题: Calling the Windows PrintScreen Function...
发信站: 哈工大紫丁香 (2000年06月05日12:44:14 星期一), 转信
发信人: gnim (我), 信区: VB
标 题: Calling the Windows PrintScreen Function....
发信站: 虎踞龙蟠 (Tue Mar 28 23:25:36 2000), 转信
发信人: yucheng (Bingo), 信区: VisualBasic
标 题: Calling the Windows PrintScreen Function....
发信站: BBS 水木清华站 (Fri Feb 25 17:47:56 2000)
Calling the Windows PrintScreen Function Using keybd_event
BAS Module Code
Add the following code to a BAS module:
----------------------------------------------------------------------------
----
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ?996-99 VBnet, Randy Birch, All Rights Reserved
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' You are free to use this code within your own applications,
' but you are expressly forbidden from selling or otherwise
' distributing this source code without prior written consent.
' This includes both posting demo projects made from this
' code as well as reproducing the code in text or html format.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte,
ByVal bScan As Byte,
ByVal dwFlags As Long,
ByVal dwExtraInfo As Long)
Public Const TheScreen = 0
Public Const TheForm = 1
'--end block--'
Form Code
To a form add a command button and either an image control or a PictureBox.
Add the following code to the form:
----------------------------------------------------------------------------
----
Private Sub Command1_Click()
'call the Windows keybd_event sub, passing the built-in
'VB keyboard constant vbKeySnapshot (44) to the sub.
'The four parameters for keybd_event are:
'BYTE bVk 'virtual-key code
'BYTE bScan 'hardware scan code
'DWORD dwFlags 'flags specifying various function options
'DWORD dwExtraInfo 'additional data associated with keystroke
'The bScan parameter value determines what
'to copy... passing 0 (TheScreen) copies
'the screen, passing 1 (TheForm) copies the
'active form.
keybd_event vbKeySnapshot, TheScreen, 0&, 0&
'pause to let Windows update the clipboard
DoEvents
'retrieve the clipboard bitmap to the control (vbCFBitmap = 2)
Image1 = Clipboard.GetData(vbCFBitmap)
End Sub
'--end block--'
--
以科计为本,以产业报国!
超越自我,飞跃无限!
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.235.249]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.042毫秒