找到了一篇资料可惜不是C#的,不太会弄:
调用SendMessage API就能够向任何带有hWnd属性的表单或者控件发送Windows消息。很多控件内置有对特定消息的响应机制。使用这一机制,你在自己的Visual Basic 6应用程序里很容易就能够实现剪切、复制和粘贴的功能。
要使用这一技巧,你就需要声明用于剪切、复制和粘贴的常数:
Private Const WM_COPY = &H301
Private Const WM_CUT = &H300
Private Const WM_PASTE = &H302
然后,声明对SendMessage API的调用:
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByValhWnd As Long, _
ByValwMsg As Long, ByValwParam As Long, lParam As Any) As Long
HWnd自变量能够接受消息发送的目的控件的句柄,而wMsg自变量会接受一个表明要被发送的是哪个对象的常数。WParam和lParam自变量被用来把其他信息同消息一起传递,但是不对WM_CUT、WM_COPY或者WM_PASTE使用。
下面是从菜单点击事件调用SendMessage API的代码:
Private Sub mnuCopy_Click()
Call SendMessage(Me.ActiveControl.hwnd, WM_COPY, 0, 0)
End Sub
Private Sub mnuCut_Click()
Call SendMessage(Me.ActiveControl.hwnd, WM_CUT, 0, 0)
End Sub
Private Sub mnuPaste_Click()
Call SendMessage(Me.ActiveControl.hwnd, WM_PASTE, 0, 0)
End Sub