请问各位VB高手可以用VB实现普通鼠标的剪切和复制功能吗?
请问各位VB高手可以用VB实现普通鼠标的剪切和复制功能吗?如果能够实现,那么应该怎么做?用到哪些函数,最好给源码!呵呵!~~~~~~...
请问各位VB高手可以用VB实现普通鼠标的剪切和复制功能吗?
如果能够实现,那么应该怎么做?用到哪些函数,最好给源码!
呵呵!~~~~~~ 展开
如果能够实现,那么应该怎么做?用到哪些函数,最好给源码!
呵呵!~~~~~~ 展开
4个回答
展开全部
1.新建模块放入下面代码。
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_CUT = &H300
Public Const WM_COPY = &H301
Public Const WM_PASTE = &H302
Public Const WM_CLEAR = &H303
Public Const WM_UNDO = &H304
2.新建窗体,添加控件TextBox,名称为mText。
并添加如下代码。
'Undo
Public Sub Undo()
Dim Ok As Long
Ok = SendMessage(mText.hwnd, EM_UNDO, 0, 0&)
End Sub
'Cut
Public Sub Cut()
Dim Ok As Long
Ok = SendMessage(mText.hwnd, WM_CUT, 0, 0&)
End Sub
'Copy
Public Sub Copy()
Dim Ok As Long
Ok = SendMessage(mText.hwnd, WM_COPY, 0, 0&)
End Sub
'Paste
Public Sub Paste()
Dim Ok As Long
Ok = SendMessage(mText.hwnd, WM_PASTE, 0, 0&)
End Sub
'Del
Public Sub Del()
Dim Ok As Long
Ok = SendMessage(mText.hwnd, WM_CLEAR, 0, 0&)
End Sub
3.在窗体中加入几个按钮,测试一下这几个函数即可。
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_CUT = &H300
Public Const WM_COPY = &H301
Public Const WM_PASTE = &H302
Public Const WM_CLEAR = &H303
Public Const WM_UNDO = &H304
2.新建窗体,添加控件TextBox,名称为mText。
并添加如下代码。
'Undo
Public Sub Undo()
Dim Ok As Long
Ok = SendMessage(mText.hwnd, EM_UNDO, 0, 0&)
End Sub
'Cut
Public Sub Cut()
Dim Ok As Long
Ok = SendMessage(mText.hwnd, WM_CUT, 0, 0&)
End Sub
'Copy
Public Sub Copy()
Dim Ok As Long
Ok = SendMessage(mText.hwnd, WM_COPY, 0, 0&)
End Sub
'Paste
Public Sub Paste()
Dim Ok As Long
Ok = SendMessage(mText.hwnd, WM_PASTE, 0, 0&)
End Sub
'Del
Public Sub Del()
Dim Ok As Long
Ok = SendMessage(mText.hwnd, WM_CLEAR, 0, 0&)
End Sub
3.在窗体中加入几个按钮,测试一下这几个函数即可。
展开全部
我RI```学了VB还真不知道有没有这功能
等达人出现顺便学习下
等达人出现顺便学习下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个问题可不是几句话能说清楚的,需要用到剪贴板API函数,如 SetClipboardData, SetClipboardViewer, ChangeClipboardChain 等,具体可查 MSDN Library 或 MSDN 站点
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
'用全局变量
dim a as string
sub Copy(byval b as string)
a=b
end sub
sub patse(byRef b as string)
b=a
end sub
sub cut(byref b as string,byval i%,byval j%)
a=mid(b,i,j)
b=mid(b,1,i-1) & mid(b,i+j)
end sub
dim a as string
sub Copy(byval b as string)
a=b
end sub
sub patse(byRef b as string)
b=a
end sub
sub cut(byref b as string,byval i%,byval j%)
a=mid(b,i,j)
b=mid(b,1,i-1) & mid(b,i+j)
end sub
参考资料: 个人编程 不得拷贝
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询