|
如何在access中使用clipboard(剪切板)啊?比如清空剪切板,向其中添加内容等
For you exampleConst LR_LOADFROMFILE = &H10
Const IMAGE_BITMAP = 0
Const IMAGE_ICON = 1
Const IMAGE_CURSOR = 2
Const IMAGE_ENHMETAFILE = 3
Const CF_BITMAP = 2
Private Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal dwImageType As Long, ByVal dwDesiredWidth As Long, ByVal dwDesiredHeight As Long, ByVal dwFlags As Long) As Long
Private Declare Function CloseClipboard Lib "user32" () 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 IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Long) As Long
Private Sub Form_Load()
hBitmap = LoadImage(App.hInstance, "c:\windows\logow.sys", IMAGE_BITMAP, 320, 200, LR_LOADFROMFILE)
If hBitmap = 0 Then
MsgBox "There was an error while loading the bitmap"
Exit Sub
End If
'open the clipboard
OpenClipboard Me.hwnd
'Clear the clipboard
EmptyClipboard
'Put our bitmap onto the clipboard
SetClipboardData CF_BITMAP, hBitmap
'Check if there's a bitmap on the clipboard
If IsClipboardFormatAvailable(CF_BITMAP) = 0 Then
MsgBox "There was an error while pasting the bitmap to the clipboard!"
End If
'Close the clipboard
CloseClipboard
'Get the picture from the clipboard
Me.Picture = Clipboard.GetData(vbCFBitmap)
End Sub
给你一个fan0217写的函数:
Function SendToScrap(strSendText As String) As Boolean
'===============================================================================
'-函数名称: SendToScrap
'-功能描述: 发送文本到剪贴板
'-输入参数说明: 必选:strSendText As String 发送的文本
'-返回参数说明: 发送成功:True 发送失败:False
'-使用语法示例: SendToScrap("你好!")
'-参考:
'-使用注意: 需要引用Microsoft Forms2.0 Object Library (%system32%\FM20.DLL)
'-兼容性:
'-作者: fan0217 fan0217@163.com
'-更新日期: 2006-02-24
'===============================================================================
On Error GoTo Err_SendToScrap
Dim tmpData As New DataObject
tmpData.SetText strSendText
tmpData.PutInClipboard
SendToScrap = True
Exit_SendToScrap:
Exit Function
Err_SendToScrap:
SendToScrap = False
MsgBox Err.Description
Resume Exit_SendToScrap
End Function
在文本框双击事件中调用:
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 '此句是保存代码,如果是新输入的内容,不加这句将复制不到内容……
SendToScrap (Me.Text1)
|
|